/images/generations and /messages block until the
model returns; tasks endpoints don’t — submit accepts your
request, returns a task_id in milliseconds, and the actual
generation runs server-side. Poll /tasks/query or stream
state changes over SSE on /tasks/stream/{task_id}.
When to use
- Video generation — every video model is long-running (10–60s+), tasks/submit is the only sane shape
- Batched image generation — fire-and-forget; reconcile results minutes later
- High-concurrency producers — keep your worker pool free from HTTP keep-alives
callback_urlintegrations — register a webhook and skip polling entirely
/messages, /chat/completions, /responses),
use the synchronous endpoints. Tasks are only for the multimodal long-tail.
Request
Headers
| Header | Required | Notes |
|---|---|---|
Authorization | yes | Bearer sk-byts-… (Anthropic-style x-api-key also accepted on this endpoint). |
content-type | yes | application/json. |
Body
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | yes | Catalog slug — see Models. Tasks endpoints only accept multimodal models (image/video). Text models reject with 400 invalid_param. |
params | object | yes | Model-specific parameters. The shape mirrors the underlying provider — e.g. for Sora 2 it’s prompt, duration_seconds, aspect_ratio; for Seedream it’s prompt, n, size. See the per-model page under API Reference → Image / Video. |
out_task_id | string | no | Your idempotency key. Submitting the same out_task_id twice with identical model + params returns the existing task (200). Conflicting params on a duplicate out_task_id returns 409 duplicate_out_task_id. |
callback_url | string | no | Webhook the gateway POSTs to when the task reaches a terminal state. |
stream | boolean | no | Reserved for /tasks/stream/{task_id} SSE delivery. Ignored on this endpoint. |
Body size cap
/v1/tasks/* bodies are capped at 1 MiB. Generous for any
reasonable params shape including small data:image/...;base64,...
inline images. Bigger inputs should upload to a URL first and pass the
URL in params.
Response
Response fields
| Field | Type | Notes |
|---|---|---|
task_id | string | Server-generated ULID. Use this for /tasks/query and /tasks/cancel. |
out_task_id | string | Echoes back if you supplied one. Omitted otherwise. |
status | string | One of pending, running, completed, failed, cancelled. Always pending on initial submit. |
estimated_credits | number | Provider’s pre-flight cost estimate in credits. Omitted if the provider doesn’t return one. Final billing uses credits_used from /tasks/query. |
estimated_seconds | integer | Provider’s pre-flight ETA in seconds. Useful for setting a polling cadence. Omitted if unknown. |
Task lifecycle
pending— dispatcher accepted the request, generation hasn’t started yetrunning— the model is generatingcompleted—outputis populated, billing is finalfailed—error_code+error_messageare populated, no billingcancelled— user called/tasks/cancelbefore terminal state
Errors
All errors use the OpenAI envelope shape (even when called withx-api-key).
| HTTP | code | When |
|---|---|---|
| 400 | invalid_param | Bad JSON, unsupported model, missing required field. |
| 401 | invalid_api_key | Missing / revoked / disabled key. |
| 409 | duplicate_out_task_id | An existing task has the same out_task_id but different params. |
| 413 | request_entity_too_large | Body > 1 MiB. Move inline base64 to a URL. |
| 429 | rate_limit_exceeded | See the Rate limits section in Pricing. |
| 500 | internal_error | Provider-side or gateway-side fault. Retry. |
Idempotency
out_task_id is your idempotency key. The dispatcher de-duplicates by
the tuple (api_key_id, out_task_id). Re-submitting the same combo
with identical params returns the original task_id and current
status — useful for retry-safe client code where a network blip would
otherwise create a duplicate render.
Pricing
Per-second (video) / per-call (image). The full live rate card is at bytespike.ai/pricing — billing only happens oncompleted; failed and cancelled tasks are free.
Next
POST /tasks/query— read a task’s current statePOST /tasks/cancel— abort a non-terminal task