API Sora 2 Pro

เชื่อมต่อ API Sora 2 Pro

สร้างเวิร์กโฟลว์ text-to-video, image-to-video และ storyboard ด้วยการ polling ที่คาดเดาได้และการควบคุมเครดิต

สิ่งที่ API Sora 2 Pro มอบให้

ทุกสิ่งที่คุณต้องการเพื่อเปิดตัว pipeline Sora 2 Pro ที่พร้อมใช้งานจริง

โมเดล 5 รูปแบบ

เลือก sora-2 text/image หรือ sora-2-pro text/image/storyboard ตามคุณภาพและต้นทุน

รองรับ Storyboard

กำหนดเรื่องราวหลายช็อตด้วย shots[] และระยะเวลาต่อช็อต

การตอบกลับแบบรวม

ทุก endpoint ส่งคืน code/message/data แม้ว่าสถานะ HTTP จะเป็น 200 เมื่อเกิดข้อผิดพลาด

การยืนยันตัวตนและ Base URL

Base URL: https://freesoragenerator.com ยืนยันตัวตนด้วย API key หรือ session cookie ที่ล็อกอินแล้ว

  • Authorization: Bearer [TOKEN] (API key sk- หรือ JWT) หรือส่ง session cookie
  • ส่ง Content-Type: application/json พร้อม POST bodies
  • ข้อผิดพลาดส่วนใหญ่ยังคงส่งคืน HTTP 200; ตรวจสอบฟิลด์ code เสมอ

Endpoint หลัก

สร้างงานด้วย /sora-pro จากนั้น poll check-result เพื่อดูสถานะ

สร้างงานสร้างวิดีโอ

ตรวจสอบ input หักเครดิต สร้างงาน และส่งคืน taskId

Method: POSTPath: /api/v1/video/sora-pro

พารามิเตอร์ Payload

  • จำเป็น หนึ่งใน sora-2-text-to-video, sora-2-image-to-video, sora-2-pro-text-to-video, sora-2-pro-image-to-video, sora-2-pro-storyboard
  • ตามเงื่อนไข จำเป็นสำหรับทุกโมเดลยกเว้น sora-2-pro-storyboard
  • ตามเงื่อนไข Base64 data URL เช่น data:image/png;base64,... จำเป็นสำหรับ image-to-video หากไม่มี imageUrl
  • ตามเงื่อนไข URL รูปภาพสาธารณะที่ใช้เมื่อไม่ได้ระบุ imageData
  • ตัวเลือก portrait หรือ landscape ค่าเริ่มต้น: landscape
  • ตัวเลือก 10, 15 หรือ 25 (storyboard เท่านั้น) ค่าเริ่มต้นแตกต่างกันตามโมเดล
  • ตัวเลือก standard หรือ high สำหรับโมเดล Pro text/image เท่านั้น
  • ตัวเลือก ลบลายน้ำสำหรับโมเดลที่ไม่ใช่ storyboard ค่าเริ่มต้น: true
  • ตามเงื่อนไข จำเป็นสำหรับ sora-2-pro-storyboard อาร์เรย์ของ '{ Scene, duration }'

หมายเหตุ

  • imageData มีความสำคัญกว่า imageUrl เมื่อระบุทั้งสองอย่าง
  • prompt เป็นตัวเลือกสำหรับ storyboard และไม่ถูกส่งไปยัง provider; ใช้ shots สำหรับเนื้อหา
  • nFrames ถูกปรับให้เป็นค่าที่อนุญาตต่อโมเดล
  • removeWatermark ค่าเริ่มต้นเป็น true สำหรับโมเดลที่ไม่ใช่ storyboard
  • shots ต้องมี Scene (ตัว S ใหญ่) และ duration > 0

ตัวอย่าง request

Text-to-video
curl -X POST https://freesoragenerator.com/api/v1/video/sora-pro \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2-pro-text-to-video",
    "prompt": "A cinematic shot of a futuristic city at sunset.",
    "aspectRatio": "landscape",
    "nFrames": "10",
    "size": "high",
    "removeWatermark": true
  }'
Image-to-video
curl -X POST https://freesoragenerator.com/api/v1/video/sora-pro \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2-image-to-video",
    "prompt": "Turn this image into a dynamic 10s clip.",
    "imageUrl": "https://example.com/reference.png",
    "aspectRatio": "portrait",
    "nFrames": "10"
  }'
Storyboard
curl -X POST https://freesoragenerator.com/api/v1/video/sora-pro \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2-pro-storyboard",
    "shots": [
      { "Scene": "Establishing shot of a city skyline at dusk", "duration": 5 },
      { "Scene": "Close-up of a runner splashing through puddles", "duration": 5 }
    ],
    "aspectRatio": "landscape",
    "nFrames": "10"
  }'

ตัวอย่าง response

{
  "code": 0,
  "message": "ok",
  "data": {
    "taskId": "281e5b0*********************f39b9"
  }
}

ตรวจสอบสถานะงาน

ดึงสถานะ ความคืบหน้า และ URL ผลลัพธ์ตาม taskId

Method: POSTPath: /api/video-generations/check-result

พารามิเตอร์ Payload

  • จำเป็น taskId ที่ส่งคืนจากการสร้าง

หมายเหตุ

  • ค่าสถานะ: pending | running | succeeded | failed | cancelled
  • result_url และ result_urls ส่งคืนลิงก์วิดีโอสุดท้ายเมื่อพร้อม

ตัวอย่าง request

curl -X POST https://freesoragenerator.com/api/video-generations/check-result \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "taskId": "281e5b0*********************f39b9"
  }'

ตัวอย่าง response

{
  "code": 0,
  "message": "Success",
  "data": {
    "status": "running",
    "progress": 35,
    "result_url": "https://your-domain.com/storage/videos/xxx.mp4",
    "result_urls": [
      "https://your-domain.com/storage/videos/xxx.mp4"
    ],
    "failure_reason": "",
    "error_message": null
  }
}

ดูเครดิตผู้ใช้

ตรวจสอบยอดเครดิตปัจจุบันก่อนส่งงาน

Method: POSTPath: /api/get-user-credits

หมายเหตุ

  • Endpoint ตัวเลือก; มีประโยชน์สำหรับการตรวจสอบก่อนดำเนินการ
  • ส่งคืน left_credits และ is_vip flags

ตัวอย่าง request

curl -X POST https://freesoragenerator.com/api/get-user-credits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

ตัวอย่าง response

{
  "code": 0,
  "message": "ok",
  "data": {
    "left_credits": 120,
    "is_vip": false
  }
}

รหัสข้อผิดพลาดทั่วไป

ข้อผิดพลาดแสดงผ่านฟิลด์ code ใน response body

  • 401: ไม่ได้รับอนุญาต
  • 402: เครดิตไม่เพียงพอ
  • -1: พารามิเตอร์โมเดลไม่ถูกต้อง
  • -1: ต้องระบุ prompt
  • -1: ต้องมีรูปภาพสำหรับ image-to-video
  • -1: ต้องระบุ shots สำหรับ storyboard
  • -1: อัปโหลดรูปภาพล้มเหลว
  • -1: สร้างบันทึกการสร้างวิดีโอล้มเหลว

ข้อมูลอ้างอิงเครดิต

เครดิตแตกต่างกันตามโมเดล ขนาด และ nFrames ใช้ตารางนี้เป็นพื้นฐาน

โมเดลพารามิเตอร์เครดิต
sora-2-text-to-video1020
sora-2-text-to-video1530
sora-2-image-to-video1020
sora-2-image-to-video1530
sora-2-pro-text-to-videostandard + 10375
sora-2-pro-text-to-videostandard + 15675
sora-2-pro-text-to-videohigh + 10825
sora-2-pro-text-to-videohigh + 151,575
sora-2-pro-image-to-videostandard + 10375
sora-2-pro-image-to-videostandard + 15675
sora-2-pro-image-to-videohigh + 10825
sora-2-pro-image-to-videohigh + 151,575
sora-2-pro-storyboard10375
sora-2-pro-storyboard15675
sora-2-pro-storyboard25675

1. สร้างงาน

POST /api/v1/video/sora-pro พร้อมโมเดลและ payload ของคุณ

2. ติดตามความคืบหน้า

Poll /api/video-generations/check-result จนกว่าสถานะจะเป็น succeeded หรือ failed

3. ตรวจสอบเครดิต

เรียก /api/get-user-credits ก่อนส่งงานจำนวนมาก (ตัวเลือก)

คำถามที่พบบ่อย

ฉันสามารถใช้ API keys หรือ session cookies ได้หรือไม่?

ได้ ส่ง Authorization: Bearer [TOKEN] (API key หรือ JWT) หรือ session cookie ที่ล็อกอินแล้ว

ฉันจะจัดรูปแบบ storyboard shots อย่างไร?

ระบุ shots เป็นอาร์เรย์ของ '{ Scene, duration }' โดย Scene เป็นตัวพิมพ์ใหญ่และ duration เป็นวินาที

ทำไมเครดิตถึงแตกต่างกันตามโมเดล?

เครดิตปรับตาม nFrames สำหรับทุกโมเดล; โมเดล Pro ยังแตกต่างกันตามขนาดด้วย

แหล่งข้อมูลที่เป็นประโยชน์

เริ่มต้นกับ API Sora 2 Pro

สร้าง API key และเปิดตัวเวิร์กโฟลว์ Sora 2 Pro แรกของคุณวันนี้