开放 API
用于创建图像/视频生成任务的 REST API。请使用账户页面的 sk- 密钥进行身份验证。
管理 API 密钥身份验证
所有请求都需要 Bearer Token。请在账户页面生成。
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx可用模型
下方的 model_id 是 open API 唯一支持的值。
| model_id | 能力 | 输出 |
|---|---|---|
seedance-2 | Seedance 2.0 (text / image to video) | video_url |
gpt-image-2 | ChatGPT Image 2 (text / image to image) | image_url |
nano-banana-2 | Nano Banana 2 (text / image to image) | image_url |
创建任务
提交生成请求。响应会返回可轮询的 task_id。
POST
/api/v1/tasks/create请求体
{
"model_id": "gpt-image-2",
"prompt": "a serene zen garden at sunrise, ultra detailed",
"image_urls": [],
"aspect_ratio": "16:9"
}cURL 示例
curl -X POST https://your-site.com/api/v1/tasks/create \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model_id": "gpt-image-2",
"prompt": "a serene zen garden at sunrise",
"aspect_ratio": "16:9"
}'响应
{
"code": 200,
"msg": "提交成功,等待生成",
"data": {
"task_id": "abcdef123456",
"request_id": "kie_xxxxxxxxxxxx",
"credits": 15
}
}提交时将扣除积分。失败的任务会自动退款。
查询任务
通过任务ID轮询任务,直到task_status达到3(成功)或4(失败)。
GET
/api/v1/tasks/{task_id}cURL 示例
curl https://your-site.com/api/v1/tasks/abcdef123456 \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"响应
{
"code": 200,
"msg": "ok",
"data": {
"task_id": "abcdef123456",
"task_status": 3,
"task_type": "image",
"model_id": "gpt-image-2",
"image_url": "https://your-cdn.com/...",
"video_url": null,
"audio_url": null,
"credits": 15,
"created_at": 1730000000
}
}task_status:1 排队中,2 运行中,3 成功,4 失败。
错误
code: 200— 成功code: 0— 业务失败(详情请查看msg字段)HTTP 401— API密钥无效或缺失