Stable, asynchronous, and decoupled from execution nodes.

Every request uses a stable logical model. Public responses never include routing details, internal job IDs, endpoints, or credentials.

Quick start

Create an API key in the console, submit a job, then use the returned job_id to look it up. Only successful jobs are charged to the account balance.

curl https://gateway.example.com/v1/images/generations \
  -H "Authorization: Bearer sk-gw-your-key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: product-asset-2026-001" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "Minimal product photo, soft daylight",
    "image_urls": [],
    "aspect_ratio": "1:1",
    "resolution": "2k"
  }'

Authentication

Every v1 endpoint uses a Bearer key.

Authorization: Bearer sk-gw-...
Never put an API key in public browser code or a Git repository. One account can create multiple keys with independent limits.
POST/v1/images/generations

Create image job

FieldTypeNotes
modelstringgpt-image-2 or a listed Nano Banana model; call GET /v1/models for the active catalog
promptstringRequired, up to 20,000 characters
image_urlsstring[]Optional; any image URL uses the model's edit operation. Limits are model-specific (up to 14).
aspect_ratioenum1:1 / 1:4 / 1:8 / 2:3 / 3:2 / 3:4 / 4:1 / 4:3 / 4:5 / 5:4 / 8:1 / 9:16 / 16:9 / 21:9 / auto
resolutionenum1k / 2k / 4k · model-specific
idempotency_keystringMay be sent in the body or the Idempotency-Key header

Response

{
  "object": "generation.job",
  "job_id": "job_...",
  "model": "gpt-image-2",
  "status": "running",
  "artifacts": [],
  "error": null,
  "price": {
    "amount_micros": 50000,
    "amount": "0.050000",
    "currency": "usd"
  }
}
POST/v1/videos/generations

Create video job

Video models share one async endpoint. Omni Flash accepts image_urls and reference_video_urls through one Gateway contract; ZexAPI and KIE map them to their own upstream fields, with at most 7 total references.

FieldTypeNotes
modelstringAny listed video model; call GET /v1/models for capabilities
promptstringRequired, up to 20,000 characters
image_urlsstring[]Optional reference images. Limits are model-specific.
reference_video_urlsstring[]Optional reference videos. Omni Flash accepts image/video references as one combined set of at most 7.
aspect_ratioenum16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 21:9
resolutionenum480p / 720p / 1080p
durationintegerModel-specific duration
generate_audiobooleanWhether to generate audio too; true by default
curl https://gateway.example.com/v1/videos/generations \
  -H "Authorization: Bearer sk-gw-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "omni-flash-v1",
    "prompt": "Create a bright product video from the references",
    "image_urls": ["https://cdn.example.com/product.png"],
    "reference_video_urls": ["https://cdn.example.com/demo.mp4"],
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 10
  }'
POST/v1/audio/generations

Create audio job

Audio models use the same asynchronous job lifecycle. The selected model controls all accepted fields.

FieldTypeNotes
modelstringAny listed audio model; call GET /v1/models for the active catalog
generation_modeenumsimple (default) / custom
promptstringRequired in simple mode; 1–20000 chars
title, style, lyricsstringRequired in custom mode; max 80 / 1000 / 5000 chars
instrumentalbooleanOptional in simple mode; custom mode is lyric-driven
model_versionenumV5 / V5_5; defaults by mode
include_timed_lyricsbooleanCustom mode only. The completed audio artifact includes verified word timing for karaoke.
idempotency_keystringMay be sent in the body or the Idempotency-Key header
curl https://gateway.example.com/v1/audio/generations
  -H "Authorization: Bearer sk-gw-your-key"
  -H "Content-Type: application/json"
  -d '{
    "model": "sunoai",
    "generation_mode": "custom",
    "title": "Late Summer Road",
    "style": "Warm acoustic folk, intimate vocal, gentle strings",
    "lyrics": "[Verse 1]\nWe drove until the sunset...",
    "model_version": "V5_5",
    "include_timed_lyrics": true
  }'
POST/v1/chat/completions

Create completion

Completions remain synchronous by default and return an OpenAI-compatible result in the same request. text-generation-v1, palm-reading-v1, and fortune-reading-v1 can opt into async job polling; async images must use publicly reachable HTTP(S) URLs, and streaming is not supported.

FieldTypeNotes
modelstringOpenRouter provider/model (default: openai/gpt-5.6-luna) / text-generation-v1 / palm-reading-v1 / fortune-reading-v1 / prompt-text-v1 / prompt-vision-v1
messagesarrayOpenAI-compatible messages; prompt-vision-v1, text-generation-v1, and palm-reading-v1 may include image_url parts in content arrays.
max_tokensintegertext-generation-v1: 64–16384; palm-reading-v1: 64–6500; fortune-reading-v1: 64–7000; Prompt models: 64–4096. Completion-capability models also accept max_completion_tokens.
temperaturenumber0–2
response_formatobjecttext-generation-v1 and report models: { type: "json_object" }
reasoning_effortenumtext-generation-v1 / OpenRouter model: none / low / medium / high; omitted means no reasoning parameter is sent
asyncbooleantext-generation-v1, palm-reading-v1, and fortune-reading-v1. Default false; true returns a job for /v1/jobs/:job_id polling. Async images must use HTTP(S) URLs.
idempotency_keystringMay be sent in the body or the Idempotency-Key header
curl https://gateway.example.com/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-your-key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: prompt-copy-2026-001" \
  -d '{
    "model": "openai/gpt-5.6-luna",
    "messages": [
      { "role": "user", "content": "Return a JSON object with three concise product tagline options." }
    ],
    "max_tokens": 512,
    "response_format": { "type": "json_object" },
    "reasoning_effort": "medium"
  }'

Async + vision

curl https://gateway.example.com/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-your-key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: async-vision-2026-001" \
  -d '{
    "model": "openai/gpt-5.6-luna",
    "async": true,
    "messages": [{
      "role": "user",
      "content": [
        { "type": "text", "text": "Analyze this image and return JSON." },
        { "type": "image_url", "image_url": { "url": "https://cdn.example.com/input.jpg" } }
      ]
    }],
    "max_completion_tokens": 12000,
    "response_format": { "type": "json_object" },
    "reasoning_effort": "high"
  }'
GET/v1/jobs/:job_id

Query job

The public status is limited to queued, running, succeeded, and failed. After success, artifacts contains image, video, or audio URLs, and completion contains text or vision completion results; polling stops at a terminal state.

curl https://gateway.example.com/v1/jobs/job_... \
  -H "Authorization: Bearer sk-gw-your-key"
GET/v1/models

Models

Returns active logical models, capabilities, and minimum–maximum price ranges without exposing their execution-node mapping. Successful jobs settle at the price of the route actually used.

Error codes

invalid_requestunauthorizedaccount_unavailablekey_limit_exceededinsufficient_balancemodel_unavailableprovider_unavailablegeneration_failedtask_timeoutinternal_error