{"openapi":"3.1.0","info":{"title":"APIMODELS API","version":"2026-12-01","summary":"One API key for image, video, audio and LLM models.","description":"APIMODELS is a multimodal AI API gateway: one key for image, video, audio and LLM models.\n\n**Model list and prices**: GET /v1/models (no key needed) lists every callable model with its `endpoint`, `async` flag, `pricing` (USD, from the same price rows billing reads) and `docs_url`. Per-model parameters (durations, resolutions, reference inputs) are documented at each model's `docs_url`; this spec covers the fields every model shares.\n\n**Async tasks**: POST /v1/images/generations, /v1/video/generations and /v1/audio/generations create a task and return `data.taskId`. Poll GET <same path>?task_id=<taskId> until `state` is `completed` (results in `resultUrls`) or `failed` (`failCode`, `retryable`), or pass `callback_url` to receive the result by webhook. An identical request (same user, model and input) repeated within 5 seconds returns the existing taskId instead of creating a second task.\n\n**Sync image mode**: POST /v1/images/generations answers synchronously in the OpenAI Images shape when `size` is a `WxH` string (e.g. `1024x1024`) or the client is the OpenAI SDK / Vercel AI SDK, and no `callback_url` is sent. `async: true` forces a task.\n\n**LLMs**: OpenAI-compatible POST /v1/chat/completions, /v1/responses, /v1/embeddings and Anthropic-compatible POST /v1/messages.\n\n**Failures**: failed tasks carry a standard `failCode` and `retryable` (CONTENT_MODERATION=false, INVALID_INPUT=false, INSUFFICIENT_BALANCE=false, UPSTREAM_BUSY=true, UPSTREAM_FAILED=true, TIMEOUT=true, INTERNAL_ERROR=true, OTHER=true). Failed tasks are not charged.\n\nDocs: https://apimodels.app/docs","contact":{"name":"APIMODELS","url":"https://apimodels.app"}},"servers":[{"url":"https://api.apimodels.app","description":"Production. `/api/v1/...` is accepted as an alias of every `/v1/...` path."}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"tags":[{"name":"Models","description":"Model catalog and prices (public)."},{"name":"Images"},{"name":"Video"},{"name":"Audio"},{"name":"Files","description":"Upload reference media and get a public URL to pass as an input."},{"name":"LLM","description":"OpenAI / Anthropic compatible text models."},{"name":"Account"}],"paths":{"/v1/models":{"get":{"tags":["Models"],"operationId":"listModels","security":[],"summary":"List models with endpoint, async flag, prices and docs links","description":"Public, no API key. OpenAI-compatible list shape; the extra fields are ignored by OpenAI clients. `?detail=0` returns only the OpenAI fields plus `modality` / `endpoint` (about a third of the size).","parameters":[{"name":"detail","in":"query","required":false,"schema":{"type":"string","enum":["0","1"],"default":"1"},"description":"`0` = slim list without aliases / async / docs_url / pricing_url / pricing."}],"responses":{"200":{"description":"Model list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelList"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}}}}},"/v1/models/{model}":{"get":{"tags":["Models"],"operationId":"retrieveModel","security":[],"summary":"Get one model by id or alias","parameters":[{"name":"model","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The model (same fields as a list entry).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Model"}}}},"404":{"description":"`model_not_found`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}}}}},"/v1/images/generations":{"post":{"tags":["Images"],"operationId":"createImage","summary":"Generate or edit images (async task, or OpenAI-compatible sync)","description":"Text-to-image when no input image is given; image editing / reference when `image` / `image_url` / `image_urls` / `images` / `image_base64` is given (the model decides which inputs it accepts — see its docs_url). Without a WxH `size`, returns a task (TaskCreated). With `size: \"WxH\"` and no `callback_url`, waits and returns the OpenAI Images shape (OpenAIImagesResponse); if generation takes longer than ~95 s the 200 status is sent early and a failure then arrives as a 200 body with `error`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageGenerationRequest"}}}},"responses":{"200":{"description":"Task created (async) or images (sync mode).","headers":{"x-apimodels-task-id":{"description":"Sync mode only: the task id behind the response.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/TaskCreatedEnvelope"},{"$ref":"#/components/schemas/OpenAIImagesResponse"},{"$ref":"#/components/schemas/OpenAIError"}]}},"text/event-stream":{"schema":{"type":"string","description":"Sync mode with `stream: true`: `: processing Ns` comments while waiting, then `event: image_generation.completed` (or `image_edit.completed`) with the first image, or `event: error`."}}}},"400":{"description":"Invalid request: missing `model` / `prompt`, unknown model (`Invalid model: …`), invalid `callback_url`, or a per-model input check failed (the message says which field).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"402":{"description":"Insufficient balance. Nothing was charged; the message states the amount needed and available.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"410":{"description":"The model has been retired. `replacement` / `alternatives` name models to switch to.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetiredModelError"}}}},"413":{"description":"Request body too large (120 MB).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"503":{"description":"Temporarily busy; the request was not run and nothing was charged. Retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}}},"get":{"tags":["Images"],"summary":"Get task status","description":"Poll a task created by any of the three generation endpoints (the three GET paths are interchangeable). Poll every 3–10 s until `state` is `completed` or `failed`, or pass `callback_url` at creation and skip polling.","parameters":[{"name":"task_id","in":"query","required":true,"description":"`data.taskId` returned when the task was created.","schema":{"type":"string"}}],"responses":{"200":{"description":"Current task state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskStatusEnvelope"}}}},"400":{"description":"`task_id` is required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"403":{"description":"The task belongs to another account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"404":{"description":"Task not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}},"operationId":"getImageTask"}},"/v1/video/generations":{"post":{"tags":["Video"],"operationId":"createVideo","summary":"Generate a video (async task)","description":"Text-to-video, image-to-video (first / last frame), reference-to-video, video edit / extend, upscale, lip-sync and more, depending on the model. Inputs and allowed values differ per model: read the model's `docs_url`. Price per second or per video is in GET /v1/models `pricing`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoGenerationRequest"}}}},"responses":{"200":{"description":"Task created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCreatedEnvelope"}}}},"400":{"description":"Invalid request: missing `model` / `prompt`, unknown model (`Invalid model: …`), invalid `callback_url`, or a per-model input check failed (the message says which field).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"402":{"description":"Insufficient balance. Nothing was charged; the message states the amount needed and available.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"410":{"description":"The model has been retired. `replacement` / `alternatives` name models to switch to.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetiredModelError"}}}},"413":{"description":"Request body too large (120 MB).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"503":{"description":"Temporarily busy; the request was not run and nothing was charged. Retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}}},"get":{"tags":["Video"],"summary":"Get task status","description":"Poll a task created by any of the three generation endpoints (the three GET paths are interchangeable). Poll every 3–10 s until `state` is `completed` or `failed`, or pass `callback_url` at creation and skip polling.","parameters":[{"name":"task_id","in":"query","required":true,"description":"`data.taskId` returned when the task was created.","schema":{"type":"string"}}],"responses":{"200":{"description":"Current task state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskStatusEnvelope"}}}},"400":{"description":"`task_id` is required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"403":{"description":"The task belongs to another account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"404":{"description":"Task not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}},"operationId":"getVideoTask"}},"/v1/audio/generations":{"post":{"tags":["Audio"],"operationId":"createAudio","summary":"Text-to-speech, music, sound effects, dubbing, transcription (async task)","description":"Fields depend on the model (e.g. TTS takes `text` and a voice; music takes `prompt` / `lyrics`; transcription takes `audio_url`). See the model's `docs_url`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AudioGenerationRequest"}}}},"responses":{"200":{"description":"Task created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCreatedEnvelope"}}}},"400":{"description":"Invalid request: missing `model` / `prompt`, unknown model (`Invalid model: …`), invalid `callback_url`, or a per-model input check failed (the message says which field).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"402":{"description":"Insufficient balance. Nothing was charged; the message states the amount needed and available.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"410":{"description":"The model has been retired. `replacement` / `alternatives` name models to switch to.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetiredModelError"}}}},"413":{"description":"Request body too large (120 MB).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"503":{"description":"Temporarily busy; the request was not run and nothing was charged. Retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}}},"get":{"tags":["Audio"],"summary":"Get task status","description":"Poll a task created by any of the three generation endpoints (the three GET paths are interchangeable). Poll every 3–10 s until `state` is `completed` or `failed`, or pass `callback_url` at creation and skip polling.","parameters":[{"name":"task_id","in":"query","required":true,"description":"`data.taskId` returned when the task was created.","schema":{"type":"string"}}],"responses":{"200":{"description":"Current task state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskStatusEnvelope"}}}},"400":{"description":"`task_id` is required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"403":{"description":"The task belongs to another account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"404":{"description":"Task not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}},"operationId":"getAudioTask"}},"/v1/files":{"post":{"tags":["Files"],"operationId":"uploadFile","summary":"Upload an image / video / audio file and get a public URL","description":"Two modes. JSON body → a presigned PUT URL (valid 600 s) plus the final public URL. multipart/form-data with field `file` → uploads directly and returns the public URL. Accepted types: `image/*`, `video/*`, `audio/*`. Limits: video 100 MB, image and audio 10 MB. Uploaded files are temporary storage for task inputs, not permanent hosting.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PresignUploadRequest"}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"Upload URL (JSON mode) or public URL (multipart mode).","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/PresignUploadEnvelope"},{"$ref":"#/components/schemas/DirectUploadEnvelope"}]}}}},"400":{"description":"Missing filename / contentType, unsupported type, file too large, or no `file` field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"413":{"description":"Body too large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}},"500":{"description":"Storage not configured or internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}}}},"/v1/chat/completions":{"post":{"tags":["LLM"],"operationId":"createChatCompletion","summary":"Chat completions (OpenAI-compatible)","description":"OpenAI Chat Completions format for every chat model in GET /v1/models (`endpoint` = /v1/chat/completions), including Claude and Gemini models. The body is forwarded with OpenAI semantics; `stream: true` returns server-sent events. Billed per token at the model's `pricing`; the charge is returned in `usage.cost` and (non-streaming) in the `x-apimodels-cost` header. Errors raised by the gateway itself use the OpenAI error shape; errors raised after model lookup (unknown model, insufficient balance, upstream error) currently use the Anthropic error shape.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"Completion (JSON) or a stream of `chat.completion.chunk` events.","headers":{"x-apimodels-request-id":{"description":"Record id; GET /v1/records/{id} returns the settled charge.","schema":{"type":"string"}},"x-apimodels-cost":{"description":"Non-streaming only: charged amount in USD.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionResponse"}},"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"Invalid JSON, missing `model`, unsupported model or wrong endpoint for the model.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"401":{"description":"Missing or invalid API key (`invalid_api_key`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"402":{"description":"Insufficient balance (`insufficient_credits`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"404":{"description":"Model not found (`model_not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"413":{"description":"Body larger than 64 MB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"429":{"description":"Upstream rate limit (`rate_limit_error`). Retry with backoff.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"500":{"description":"Internal or upstream error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}}}}},"/v1/messages":{"post":{"tags":["LLM"],"operationId":"createMessage","summary":"Messages (Anthropic-compatible)","description":"Anthropic Messages format (Claude Code, Anthropic SDK). Accepts the Anthropic request body for Claude and Gemini models; OpenAI-family models must use /v1/chat/completions. Errors use the Anthropic error shape.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/chat/completions`. Matching is case-insensitive."},"messages":{"type":"array","items":{"type":"object"}},"max_tokens":{"type":"integer","minimum":1,"description":"Defaults when omitted: Claude 1024, Gemini 8192."},"system":{},"stream":{"type":"boolean","default":false}},"additionalProperties":true}}}},"responses":{"200":{"description":"Anthropic Message (or SSE stream when `stream: true`).","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}},"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnthropicError"}}}},"401":{"description":"Invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnthropicError"}}}},"402":{"description":"Insufficient balance.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnthropicError"}}}}}}},"/v1/responses":{"post":{"tags":["LLM"],"operationId":"createResponse","summary":"Responses (OpenAI-compatible)","description":"OpenAI Responses API format for chat models. Errors: `{ \"error\": { \"message\", \"type\", \"code\" } }`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model"],"properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/chat/completions`. Matching is case-insensitive."},"input":{},"stream":{"type":"boolean","default":false}},"additionalProperties":true}}}},"responses":{"200":{"description":"OpenAI Response object (or SSE stream).","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}},"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"401":{"description":"Invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"402":{"description":"Insufficient balance.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}}}}},"/v1/embeddings":{"post":{"tags":["LLM"],"operationId":"createEmbedding","summary":"Embeddings (OpenAI-compatible)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","input"],"properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/embeddings`. Matching is case-insensitive."},"input":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"dimensions":{"type":"integer"},"encoding_format":{"type":"string","enum":["float","base64"]}},"additionalProperties":true}}}},"responses":{"200":{"description":"OpenAI embedding list.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"`model` and `input` are required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"401":{"description":"Invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"402":{"description":"`insufficient_credits`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}},"404":{"description":"`model_not_found`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIError"}}}}}}},"/v1/balance":{"get":{"tags":["Account"],"operationId":"getBalance","summary":"Account balance (USD)","responses":{"200":{"description":"Balance.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BalanceEnvelope"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvelopeError"}}}}}}}},"webhooks":{"taskCompleted":{"post":{"summary":"Task finished (sent to `callback_url`)","description":"Sent once when a task reaches `completed` or `failed` (no intermediate states). `Content-Type: application/json`, no signature header — treat the body as a hint and confirm with GET …/generations?task_id=. Delivery: up to 3 attempts per round (10 s timeout each), then retry rounds after 30 s, 2 min, 8 min and 10 min; gives up after 5 rounds. Any 2xx response counts as delivered. The outer `code` is always 200, also for failed tasks; result URLs are inside the `resultJson` string (there is no top-level `resultUrls` here).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallbackPayload"}}}},"responses":{"200":{"description":"Any 2xx acknowledges delivery."}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"`Authorization: Bearer <API key>`. Create keys at https://apimodels.app/console/api-keys."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"x-api-key","description":"Alternative to the Bearer header (also accepted: `x-goog-api-key`)."}},"schemas":{"EnvelopeError":{"type":"object","required":["code","msg"],"properties":{"code":{"type":"integer","description":"Same as the HTTP status."},"msg":{"type":"string"}}},"RetiredModelError":{"type":"object","required":["code","msg"],"properties":{"code":{"type":"integer","const":410},"msg":{"type":"string"},"replacement":{"type":"string"},"alternatives":{"type":"array","items":{"type":"string"}},"retired_at":{"type":"string"},"announced_at":{"type":"string"}}},"OpenAIError":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":["string","null"]},"task_id":{"type":"string","description":"Sync image mode: the failed task."}}}}},"AnthropicError":{"type":"object","required":["type","error"],"properties":{"type":{"type":"string","const":"error"},"error":{"type":"object","required":["type","message"],"properties":{"type":{"type":"string"},"message":{"type":"string"}}}}},"FailCode":{"type":"string","enum":["CONTENT_MODERATION","INVALID_INPUT","INSUFFICIENT_BALANCE","UPSTREAM_BUSY","UPSTREAM_FAILED","TIMEOUT","INTERNAL_ERROR","OTHER"],"description":"Standard failure class. retryable: CONTENT_MODERATION=false, INVALID_INPUT=false, INSUFFICIENT_BALANCE=false, UPSTREAM_BUSY=true, UPSTREAM_FAILED=true, TIMEOUT=true, INTERNAL_ERROR=true, OTHER=true. Retry (same or another model) only when retryable is true; otherwise fix the input, the prompt or the balance."},"Pricing":{"type":"object","required":["currency","unit","from","tiers"],"description":"List price in USD, derived from the price rows billing reads. Account-specific discounts are not applied. When `unit` is `see_docs` the billing rule cannot be stated as one unit (token-based video, durations probed from input media, etc.): read `docs_url`; `tiers` then lists the raw numeric price table, if any.","properties":{"currency":{"type":"string","const":"USD"},"unit":{"type":"string","enum":["per_image","per_second","per_video","per_request","per_minute","per_1k_characters","per_1k_bytes","per_1m_tokens","see_docs"]},"from":{"type":["number","null"],"description":"Lowest non-zero tier price in `unit`. For per_1m_tokens: the input price (off-peak for time-based models). null for see_docs."},"tiers":{"type":"array","description":"Price per tier. Keys are resolutions (`1K`, `720p`), resolution-quality (`1K-medium`), resolution_seconds (`720p_8`), `default`, or `input` / `output` / `cache_read` / `cache_write` (per 1M tokens; `*_peak` for peak hours).","items":{"type":"object","required":["key","price"],"properties":{"key":{"type":"string"},"price":{"type":"number"},"unit":{"type":"string","description":"Present only when this tier's unit differs from the top-level unit."}}}},"addons":{"type":"array","description":"Charges added on top of the tier price (reference images, reference-video seconds…).","items":{"type":"object","required":["key","price","unit"],"properties":{"key":{"type":"string"},"price":{"type":"number"},"unit":{"type":"string"}}}},"long_context":{"type":"object","description":"When one request's input exceeds threshold_tokens, all its token prices are multiplied.","properties":{"threshold_tokens":{"type":"integer"},"input_multiplier":{"type":"number"},"output_multiplier":{"type":"number"}}},"time_based":{"type":"object","description":"Peak-hour pricing: base tiers are off-peak, `*_peak` tiers apply during peak_hours_utc.","properties":{"peak_hours_utc":{"type":"array","items":{"type":"integer"}},"peak_weekdays_only":{"type":"boolean"}}},"promo":{"type":"object","description":"Limited-time price: tier price × factor until `until` (UTC). factor 0 = free.","properties":{"factor":{"type":"number"},"until":{"type":"string","format":"date-time"}}},"note":{"type":"string"}}},"Model":{"type":"object","required":["id","object","created","owned_by"],"properties":{"id":{"type":"string","description":"Model id to send as `model`."},"object":{"type":"string","const":"model"},"created":{"type":"integer","description":"Unix seconds."},"owned_by":{"type":"string","const":"apimodels"},"modality":{"type":"string","enum":["chat","image","video","audio","embedding","decision"]},"endpoint":{"type":"string","description":"Path to call (absolute wss:// URL for realtime voice).","examples":["/v1/images/generations"]},"aliases":{"type":"array","items":{"type":"string"},"description":"Other accepted spellings of `id`."},"async":{"type":"boolean","description":"true = the endpoint returns a task to poll (or deliver by callback_url)."},"docs_url":{"type":["string","null"],"format":"uri","description":"Parameters, limits and examples for this model."},"pricing_url":{"type":["string","null"],"format":"uri","description":"Model page with the price table."},"pricing":{"$ref":"#/components/schemas/Pricing"}}},"ModelList":{"type":"object","required":["object","data"],"properties":{"object":{"type":"string","const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Model"}}}},"ImageGenerationRequest":{"type":"object","required":["model"],"additionalProperties":true,"description":"`prompt` is required except for upscalers and layer decomposition. Model-specific fields (quality, background, output_format, seed, negative_prompt, tier, width / height…) are passed through; see the model's docs_url.","properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/images/generations`. Matching is case-insensitive."},"prompt":{"type":"string"},"image":{"type":"string","description":"One input image: URL, data URI or raw base64."},"image_url":{"type":"string","format":"uri"},"image_base64":{"type":"string"},"image_mime_type":{"type":"string","default":"image/jpeg"},"image_urls":{"type":"array","items":{"type":"string"},"description":"Several input / reference images. `images` is an alias; both are merged."},"images":{"type":"array","items":{"type":"string"}},"mask":{"type":"string","description":"Mask for inpainting (URL, data URI or base64); also `mask_url` / `mask_base64`."},"aspect_ratio":{"type":"string","examples":["16:9","1:1","9:16"]},"resolution":{"type":"string","description":"Output tier, e.g. `1K`, `2K`, `4K` (upper-cased). Selects the price tier.","examples":["1K","2K","4K"]},"size":{"type":"string","description":"`WxH` (e.g. `1024x1024`) switches to the OpenAI-compatible sync response and implies aspect_ratio + resolution when they are not given."},"n":{"type":"integer","minimum":1,"maximum":9,"default":1,"description":"Number of images, for models that support it."},"quality":{"type":"string","examples":["low","medium","high"]},"response_format":{"type":"string","enum":["url","b64_json"],"description":"Sync mode: `url` omits b64_json (default includes both)."},"stream":{"type":"boolean","default":false,"description":"Sync mode: answer as server-sent events."},"async":{"type":"boolean","default":false,"description":"true forces task mode even with a WxH size."},"callback_url":{"type":"string","format":"uri","description":"Optional webhook. When the task reaches `completed` or `failed`, we POST the `taskCompleted` webhook payload here. Must be a public http(s) URL (localhost / private / link-local addresses are rejected with 400). Only the snake_case name `callback_url` is read on these endpoints."}}},"VideoGenerationRequest":{"type":"object","required":["model"],"additionalProperties":true,"description":"Common fields; each model reads the subset it supports and validates values (allowed durations, resolutions, number of references). See the model's docs_url.","properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/video/generations`. Matching is case-insensitive."},"prompt":{"type":"string"},"duration":{"oneOf":[{"type":"integer"},{"type":"string"}],"description":"Seconds. Allowed values depend on the model."},"resolution":{"type":"string","examples":["480p","720p","1080p","4k"],"description":"Selects the price tier."},"aspect_ratio":{"type":"string","examples":["16:9","9:16","1:1"]},"image":{"type":"string","description":"First frame (URL or data URI) for image-to-video models. Also accepted: `image_url`, `first_frame_url`."},"first_frame_url":{"type":"string","format":"uri"},"last_frame_url":{"type":"string","format":"uri"},"images":{"type":"array","items":{"type":"string"}},"reference_image_urls":{"type":"array","items":{"type":"string","format":"uri"}},"reference_video_urls":{"type":"array","items":{"type":"string","format":"uri"}},"reference_audio_urls":{"type":"array","items":{"type":"string","format":"uri"}},"video_url":{"type":"string","format":"uri","description":"Source video for edit / extend / upscale / lip-sync models."},"audio_url":{"type":"string","format":"uri","description":"Driving audio for lip-sync / talking-avatar models."},"generate_audio":{"type":"boolean","description":"Models with native audio: generate a soundtrack."},"negative_prompt":{"type":"string"},"seed":{"type":"integer"},"callback_url":{"type":"string","format":"uri","description":"Optional webhook. When the task reaches `completed` or `failed`, we POST the `taskCompleted` webhook payload here. Must be a public http(s) URL (localhost / private / link-local addresses are rejected with 400). Only the snake_case name `callback_url` is read on these endpoints."}}},"AudioGenerationRequest":{"type":"object","required":["model"],"additionalProperties":true,"description":"Fields depend on the model; see its docs_url.","properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/audio/generations`. Matching is case-insensitive."},"text":{"type":"string","description":"Text to speak (TTS models)."},"prompt":{"type":"string","description":"Music / sound-effect description."},"voice_id":{"type":"string"},"lyrics":{"type":"string"},"duration":{"type":"string"},"audio_url":{"type":"string","format":"uri","description":"Input audio (transcription, isolation)."},"video_url":{"type":"string","format":"uri","description":"Input video (video-to-audio)."},"source_url":{"type":"string","format":"uri","description":"Dubbing source."},"target_lang":{"type":"string"},"callback_url":{"type":"string","format":"uri","description":"Optional webhook. When the task reaches `completed` or `failed`, we POST the `taskCompleted` webhook payload here. Must be a public http(s) URL (localhost / private / link-local addresses are rejected with 400). Only the snake_case name `callback_url` is read on these endpoints."}}},"TaskCreatedEnvelope":{"type":"object","required":["code","msg","data"],"properties":{"code":{"type":"integer","const":200},"msg":{"type":"string","const":"success"},"data":{"type":"object","required":["taskId","state","model"],"properties":{"taskId":{"type":"string","description":"Pass as `task_id` when polling."},"state":{"type":"string","const":"pending"},"model":{"type":"string"},"reservedCredits":{"type":"number","description":"USD held for this task; settled when it completes, released if it fails."},"currency":{"type":"string","const":"USD"}}}}},"TaskStatus":{"type":"object","required":["taskId","state","model"],"properties":{"taskId":{"type":"string"},"state":{"type":"string","enum":["pending","processing","completed","failed"]},"model":{"type":"string"},"resultUrls":{"type":"array","items":{"type":"string","format":"uri"},"description":"Present when completed. Download and store results: hosted files are temporary (about 30 days)."},"images":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"width":{"type":"integer"},"height":{"type":"integer"}}},"description":"Image tasks: measured size per result, same order as resultUrls."},"resultJson":{"type":["string","null"],"description":"JSON string with resultUrls and model-specific extras (layers, videoDuration…)."},"failCode":{"oneOf":[{"$ref":"#/components/schemas/FailCode"},{"type":"null"}]},"failMsg":{"type":["string","null"]},"retryable":{"type":"boolean","description":"Present when failed."},"credits":{"type":"number","description":"Charged amount in USD (0 until completed; failed tasks are not charged)."},"currency":{"type":"string","const":"USD"},"usage":{"type":"object","additionalProperties":true,"description":"Token usage for token-billed image models."},"costTime":{"type":["integer","null"],"description":"Processing time in ms."},"createTime":{"type":"integer","description":"Unix ms."},"completeTime":{"type":["integer","null"],"description":"Unix ms."},"param":{"type":"string","description":"JSON string of the input parameters."},"modelDisplayName":{"type":"string"},"modelType":{"type":"string"}}},"TaskStatusEnvelope":{"type":"object","required":["code","msg","data"],"properties":{"code":{"type":"integer","const":200},"msg":{"type":"string"},"data":{"$ref":"#/components/schemas/TaskStatus"}}},"CallbackPayload":{"type":"object","required":["code","msg","data"],"properties":{"code":{"type":"integer","const":200},"msg":{"type":"string","const":"success"},"data":{"type":"object","required":["taskId","model","state"],"properties":{"taskId":{"type":"string"},"model":{"type":"string"},"state":{"type":"string","enum":["completed","failed"]},"param":{"type":"string","description":"JSON string of the input parameters."},"resultJson":{"type":["string","null"],"description":"JSON string; `resultUrls` inside it when completed."},"failCode":{"oneOf":[{"$ref":"#/components/schemas/FailCode"},{"type":"null"}]},"failMsg":{"type":["string","null"]},"costTime":{"type":["integer","null"]},"completeTime":{"type":["integer","null"]},"createTime":{"type":"integer"},"credits":{"type":"number","description":"USD charged."},"usage":{"type":"object","additionalProperties":true},"currency":{"type":"string","const":"USD"}}}}},"OpenAIImagesResponse":{"type":"object","required":["created","data"],"properties":{"created":{"type":"integer"},"data":{"type":"array","items":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri"},"b64_json":{"type":"string"},"width":{"type":"integer"},"height":{"type":"integer"}}}},"size":{"type":"string","description":"Actual output size `WxH`."},"usage":{"type":"object","additionalProperties":true}}},"PresignUploadRequest":{"type":"object","required":["filename","contentType"],"properties":{"filename":{"type":"string"},"contentType":{"type":"string","description":"`image/*`, `video/*` or `audio/*`."},"fileSize":{"type":"integer","description":"Bytes; checked against the size limit when given."}}},"PresignUploadEnvelope":{"type":"object","properties":{"code":{"type":"integer","const":200},"msg":{"type":"string"},"data":{"type":"object","required":["uploadUrl","publicUrl","expiresAt"],"properties":{"uploadUrl":{"type":"string","format":"uri","description":"PUT the file here with the same Content-Type."},"publicUrl":{"type":"string","format":"uri"},"expiresAt":{"type":"string","format":"date-time"}}}}},"DirectUploadEnvelope":{"type":"object","properties":{"code":{"type":"integer","const":200},"msg":{"type":"string"},"data":{"type":"object","required":["publicUrl"],"properties":{"publicUrl":{"type":"string","format":"uri"}}}}},"ChatCompletionRequest":{"type":"object","required":["model","messages"],"additionalProperties":true,"properties":{"model":{"type":"string","description":"Model id. Use an `id` (or one of its `aliases`) from GET /v1/models whose `endpoint` is `/v1/chat/completions`. Matching is case-insensitive."},"messages":{"type":"array","items":{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["system","developer","user","assistant","tool"]},"content":{}},"additionalProperties":true}},"stream":{"type":"boolean","default":false},"max_tokens":{"type":"integer","description":"Also used for the balance pre-check. Defaults when omitted: Claude 1024, Gemini 8192, others 4096."},"max_completion_tokens":{"type":"integer"},"temperature":{"type":"number"},"tools":{"type":"array","items":{"type":"object"}},"response_format":{"type":"object"},"reasoning_effort":{"type":"string"}}},"ChatCompletionResponse":{"type":"object","additionalProperties":true,"properties":{"id":{"type":"string"},"object":{"type":"string","const":"chat.completion"},"created":{"type":"integer"},"model":{"type":"string"},"choices":{"type":"array","items":{"type":"object","additionalProperties":true}},"usage":{"type":"object","additionalProperties":true,"properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"},"cost":{"type":"object","properties":{"currency":{"type":"string","const":"USD"},"amount":{"type":"number","description":"List price of this call."},"discount":{"type":"number"},"charged":{"type":"number","description":"Amount charged."}}}}}}},"BalanceEnvelope":{"type":"object","properties":{"code":{"type":"integer","const":200},"msg":{"type":"string"},"data":{"type":"object","properties":{"balance":{"type":"number","description":"Available USD (total − frozen)."},"total":{"type":"number"},"frozen":{"type":"number","description":"Held by running tasks."},"currency":{"type":"string","const":"USD"}}}}}}}}