logo Omni Video

Open API

用於建立圖片/影片生成任務的 REST API。請使用帳戶頁面的 sk- 金鑰進行驗證。

管理 API 金鑰

驗證

所有請求都需要 bearer token。請至帳戶頁面產生。

Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

可用模型

下方的 model_id 僅為 open API 可接受的值。

model_id功能輸出
seedance-2Seedance 2.0 (text / image to video)video_url
gpt-image-2ChatGPT Image 2 (text / image to image)image_url
nano-banana-2Nano 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 金鑰無效或缺失