Przejdź do głównej treści

Endpointy

MetodaEndpointOpis
POST/api/v1/generateTask/kling-2-6Utwórz zadanie generowania
GET/api/v1/statusTask/kling-2-6Sprawdź 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": "auto",
  "input": {
    "mode": "text-to-video",
    "prompt": "...",
    "duration": 10,
    "sound": true,
    "aspect_ratio": "16:9",
    "image_urls": ["..."]
  }
}

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:"auto"
Routing strategy: auto, value, or official
input
object
wymagane
Model input parameters
Mode Options:
  • text-to-video — Generate video from text
  • image-to-video — Generate video from image

Przykład

Text-to-Video
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-6" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "provider": "value",
    "input": {
      "mode": "text-to-video",
      "prompt": "a serene waterfall in the forest with birds chirping",
      "duration": 10,
      "sound": true,
      "aspect_ratio": "16:9"
    }
  }'
Image-to-Video
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-6" \
  -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": "animate this mountain view with moving clouds and wind sounds",
      "duration": 5,
      "sound": true,
      "image_urls": ["https://example.com/ref.jpg"]
    }
  }'

Odpowiedź

POST /api/v1/generateTask/kling-2-6

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
}

GET /api/v1/statusTask/kling-2-6

Query task execution status and results via taskId.
curl -X GET "https://api.apixo.ai/api/v1/statusTask/kling-2-6?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": 1767965652317,
    "costTime": 41388
  }
}
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
Requests10000 / minute
Concurrent tasks1000
Exceeding limits returns 429 error. Wait and retry.

Wskazówki

  • Generation time:
    • 5-second video: ~50-70 seconds
    • 10-second video: ~80-100 seconds
    • Submit task, wait 50 seconds, then poll every 5 seconds
  • Audio generation: Kling 2.6’s key feature is audio generation:
    • sound: true: Auto-generates matching ambient sounds and background music
    • sound: false: Generates silent video
    • Describe sound effects in prompt for better audio (e.g., “birds chirping”, “water flowing”)
  • Callback mode: Video generation takes time, 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.
  • Aspect ratio selection:
    • 1:1: Square, for social media (default)
    • 16:9: Landscape, for traditional video platforms
    • 9:16: Portrait, for short video platforms
  • Image formats: image_urls supports JPG, PNG, WebP, max 10MB per image.
  • Prompt tips: Describe both visual and audio effects in prompts for better audio-video synchronization.

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

Powiązane