オープンAPI
画像/動画生成タスクを作成するためのREST API。アカウントページのsk-キーで認証してください。
APIキーを管理認証
すべてのリクエストにはベアラートークンが必要です。アカウントページから生成してください。
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx利用可能なモデル
下記のmodel_id値のみがオープン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
}
}送信時にクレジットが差し引かれます。失敗したタスクは自動で返金されます。
タスクを照会
task_statusが3(成功)または4(失敗)になるまで、IDでタスクをポーリングします。
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キーが無効または未入力