/api/v1/user_task/asyncCreateWithCost。kexiangai.com 生态),调用前应由用户自行确认可信性与合规性。--use-local-key 时才读取 ~/.config/image2/.env。X_API_KEY,避免不必要的本地持久化。curl、python3grep、cut、tr、tail(仅 --use-local-key 模式)X_API_KEY(推荐)IMAGE2_BASE_URL(默认 https://kexiangai.com)你是 "image2 任务创建与查询" 技能。你的职责是稳定、可重复地创建 image2 图片任务,并在创建成功后主动查询直到返回最终结果。
x-api-key,日志与回显仅允许掩码展示。img2img 模式下 urls 为必填,且最多 8 张。text2img)img2img)1:1、3:4、16:9)触发短语示例:
x-api-key:必填,请求头字段,获取地址 kexiangai.comcost_type:固定 1business_url:固定 gpt-image2/imguser_input.modelName:默认 GPT-Image-2user_input.modelType:必填,text2img 或 img2imguser_input.prompt:必填,字符串user_input.size:必填,比例字符串user_input.urls:img2img 必填,URL 字符串数组,最多 8 项支持的 size:
auto1:13:22:316:99:164:33:421:99:211:33:12:11:2支持用户首次配置后长期复用,无需每次重复输入。
x-api-keyX_API_KEY~/.config/image2/.env(仅在显式允许时读取)mkdir -p ~/.config/image2
cat > ~/.config/image2/.env << 'EOF'
X_API_KEY=你的x-api-key
EOF
chmod 600 ~/.config/image2/.env
详细字段说明见 references/api-guide.md。
curl --location 'https://kexiangai.com/api/v1/user_task/asyncCreateWithCost' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR_X_API_KEY>' \
--data '{
"cost_type": 1,
"business_url": "gpt-image2/img",
"user_input": {
"modelName": "GPT-Image-2",
"modelType": "text2img",
"prompt": "为护肤产品生成一张极简海报",
"size": "3:4"
}
}'
curl --location 'https://kexiangai.com/api/v1/user_task/get/passAuth/<TASK_ID>' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR_X_API_KEY>'
prompt、modelType、sizeurls(当 modelType=img2img)x-api-key(可从优先级策略自动读取)modelType 仅允许 text2img 或 img2imgsize 必须在支持列表内prompt 必须非空img2img 时:urls 必须为 URL 字符串数组,长度 1-8text2img 时:urls 默认为空数组(可省略)/api/v1/user_task/asyncCreateWithCostcost_type=1、business_url=gpt-image2/imgContent-Type: application/json + x-api-keyid 与参数摘要,避免同轮重复提交/api/v1/user_task/get/passAuth/{id}task_status 为 pending/running 持续轮询task_status=success:返回最终结果(优先 service_output.imgUrls、其次 service_output.imgUrl)task_status=failed/error/canceled:返回失败状态与 service_output.failReasonx-api-key:提示去 kexiangai.com 获取,并说明可用 scripts/set_key.sh 持久化prompt:提示补充提示词后再创建modelType 非法:提示仅支持 text2img/img2imgsize 非法:返回支持列表并要求重选img2img 缺少 urls:提示至少提供 1 张参考图 URLurls 超过 8 张:提示精简到 8 张以内在最终响应前逐项检查:
img2img 的 urls 约束# 1) 首次配置 key(只需一次)
mkdir -p ~/.config/image2
./scripts/set_key.sh
# 2) 会话变量方式(推荐)
export X_API_KEY='你的x-api-key'
# 3) text2img 任务创建
curl --location 'https://kexiangai.com/api/v1/user_task/asyncCreateWithCost' \
--header 'Content-Type: application/json' \
--header "x-api-key: $X_API_KEY" \
--data '{
"cost_type": 1,
"business_url": "gpt-image2/img",
"user_input": {
"modelName": "GPT-Image-2",
"modelType": "text2img",
"prompt": "生成科技风产品海报",
"size": "16:9"
}
}'
# 4) img2img 任务创建
curl --location 'https://kexiangai.com/api/v1/user_task/asyncCreateWithCost' \
--header 'Content-Type: application/json' \
--header "x-api-key: $X_API_KEY" \
--data '{
"cost_type": 1,
"business_url": "gpt-image2/img",
"user_input": {
"modelName": "GPT-Image-2",
"modelType": "img2img",
"prompt": "基于参考图生成新品海报",
"size": "3:4",
"urls": ["https://example.com/reference.png"]
}
}'
# 5) 按任务 ID 查询
curl --location "https://kexiangai.com/api/v1/user_task/get/passAuth/${TASK_ID}" \
--header 'Content-Type: application/json' \
--header "x-api-key: $X_API_KEY"
./scripts/set_key.sh:交互输入并保存 key 到 ~/.config/image2/.envecho '你的x-api-key' | ./scripts/set_key.sh --stdin:从标准输入保存 keyX_API_KEY='你的x-api-key' ./scripts/create_task.sh --mode text2img --prompt "提示词" --size "3:4"X_API_KEY='你的x-api-key' ./scripts/create_task.sh --mode img2img --prompt "提示词" --size "3:4" --url "https://example.com/1.png"SKILL.mdscripts/set_key.shscripts/create_task.shreferences/api-guide.mdassets/X_API_KEY,必要时再走本地 .env)x-api-key(kexiangai.com)modelType(text2img/img2img)prompt 与 sizeimg2img,收集 urls(1-8 张)description 是否覆盖真实表达(如"生成图片""图生图""16:9 封面图")When would you use the image2 skill?pending 是正常中间状态success 或失败态modelType、size、urls 数量与格式business_url 固定为 gpt-image2/img共 2 个版本