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

เนื้อหา Request

{
  "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 key ไม่ถูกต้องหรือไม่มี