跳转到主要内容

接口

MethodEndpointDescription
POST/api/v1/generateTask/sora-2-pro创建生成任务
GET/api/v1/statusTask/sora-2-pro查询任务状态

认证

所有请求需在请求头中携带 API Key:
Authorization: Bearer YOUR_API_KEY

Request Body

{
  "request_type": "async",
  "callback_url": "https://...",
  "provider": "official",
  "input": {
    "mode": "text-to-video",
    "prompt": "...",
    "duration": 8,
    "size": "720*1280"
  }
}

Parameters

request_type
string
默认值:"async"
async (polling) or callback (webhook)
callback_url
string
Callback URL, required when request_type=callback (conditional)
provider
string
默认值:"official"
Routing strategy. Only official is supported; always set provider=official explicitly.
input
object
必填
Model input parameters
Mode Options:
  • text-to-video — Generate video from text prompt
  • image-to-video — Generate video from reference image

Example

Text-to-Video
curl -X POST "https://api.apixo.ai/api/v1/generateTask/sora-2-pro" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "provider": "official",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic tracking shot of a futuristic city with flying cars",
      "duration": 8,
      "size": "1280*720"
    }
  }'
Image-to-Video
curl -X POST "https://api.apixo.ai/api/v1/generateTask/sora-2-pro" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/callback",
    "provider": "official",
    "input": {
      "mode": "image-to-video",
      "prompt": "make this image come alive with subtle motion",
      "duration": 12,
      "resolution": "1080p",
      "image_urls": [
        "https://example.com/reference_image.jpg"
      ]
    }
  }'

Response

POST /api/v1/generateTask/sora-2-pro

Returns taskId on success for subsequent status queries. Success:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Error:
{
  "code": 400,
  "message": "Insufficient credits",
  "data": null
}
{
  "code": 400,
  "message": "Content violates provider policy, please adjust the prompt",
  "data": null
}

GET /api/v1/statusTask/sora-2-pro

Query task execution status and results via taskId.
curl -X GET "https://api.apixo.ai/api/v1/statusTask/sora-2-pro?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Success:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965730929,
    "costTime": 120000
  }
}
Failed:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines"
  }
}

Status Response Fields

taskId
string
Unique task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing resultUrls array. Only present on success. Parse with JSON.parse().
failCode
string
Error code. Only present when state is failed. See Error Codes.
failMsg
string
Human-readable error message. Only present when state is failed.
createTime
integer
Task creation timestamp (Unix milliseconds).
completeTime
integer
Task completion timestamp (Unix milliseconds).
costTime
integer
Processing duration in milliseconds.

Error Codes

CodeDescription
400Invalid parameters or request error
401Invalid or missing API Key
429Rate limit exceeded
Fail CodeDescription
CONTENT_VIOLATIONContent violates safety guidelines
INVALID_IMAGE_URLCannot access provided image URL

速率限制

LimitValue
Requests60 / minute
Concurrent tasks10
Exceeding limits returns 429 error. Wait and retry.

Tips

  • Generation time: Average ~3 minutes per video. Submit task, wait 120 seconds, then poll every 5 seconds.
  • Routing recommendation: Always include provider=official explicitly in request body.
  • Callback mode: Due to long generation times, strongly recommend using callback mode.
  • Video expiration: Result URLs are valid for 15 days. Download promptly.
  • Content moderation: Prompts must comply with content safety guidelines. Violations return CONTENT_VIOLATION.
  • Image formats: image_urls supports JPG, PNG, WebP, max 10MB per image.
  • Duration options: Use 4, 8, or 12 seconds depending on preview vs final output needs.
  • Official route duration policy: Under provider=official, duration values should be explicitly set to 4, 8, or 12.
  • Size vs Resolution:
    • size is used in text-to-video mode: 720*1280 (portrait), 1280*720 (landscape), 1024*1792, 1792*1024
    • resolution is used in image-to-video mode: 720p or 1080p

Video generation takes longer than images — use callback mode for production workloads. Result URLs expire after 15 days; download important outputs promptly.