Przejdź do głównej treści

Endpointy

MetodaEndpointOpis
POST/api/v1/generateTask/sora-2-proUtwórz zadanie generowania
GET/api/v1/statusTask/sora-2-proSprawdź status zadania

Uwierzytelnianie

Wszystkie żądania wymagają klucza API w nagłówku:
Authorization: Bearer YOUR_API_KEY

Treść żądania

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

Parametry

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

Przykład

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"
      ]
    }
  }'

Odpowiedź

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"
  }
}

Pola odpowiedzi statusu

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 Kody błędów.
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.

Kody błędów

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

Limity rate

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

Wskazówki

  • 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.

Powiązane