Generate an image
POST/api/v1/images
Prices the request, charges the credits and queues the job; the answer comes at once with status: pending. Poll GET with the id, or register a webhook. A failed job is refunded in full.
Parameters
- Idempotency-Keyheader · string
- Any unique string. Sending the same request again with the same key returns the same generation (200, header
Idempotent-Replayed: true) and charges nothing more. The same key with a different request:idempotency_key_reused(422).max 255 chars
Request body
The prompt plus the options of one model. Every option that changes the price is explicit and required by its model (see GET /api/v1/models): unknown or missing options are refused with invalid_parameters. Without model, the style's model is used, then your defaults (GET /api/v1/defaults), then camerino's.
- promptstring · required
- What to generate, in any language.max 4000 chars
- modelstring
- A model that makes an image (
taskin GET /api/v1/models); another one is refused withwrong_task. Default when no style or default names one:nano-banana-2. - resolutionstring
- Required by Nano Banana models, e.g.
1k,2k,4k. - qualitystring
- Required by GPT Image 2, e.g.
medium. - sizestring
- Required by GPT Image 2, e.g.
1024x1024. - aspect_ratio"4:3" | "3:4" | "16:9" | "9:16" | "1:1" | "3:2" | "2:3" | "4:5" | "5:4" | "21:9"
- Format; which ones a model offers is in GET /api/v1/models. It never changes the price.
- referencesReference[]
- Reference images, or first and last frame of a video. They never change the price.max 14 items
- stylestring
- Id or name of one of your styles.max 100 chars
- max_creditsinteger
- Refuse the request with
price_above_max(422) if it would cost more than this. Nothing is charged.≥ 1 - webhook_urlstring
- Notify this https address instead of your registered webhook. You need a registered webhook anyway: its secret signs the notification.max 2000 chars
Responses
- 200Replay of a request already received with this Idempotency-Key. Nothing charged. Returns Generation.
- 202Created and queued. Returns Generation.
- 400Invalid request. Codes:
invalid_json,invalid_prompt,invalid_max_credits,invalid_webhook_url,invalid_references,invalid_style,invalid_parameters,wrong_task,not_available,webhook_not_configured,invalid_url,empty_file. - 401Missing, malformed, invalid or revoked API key. Codes:
unauthorized. - 402Not enough credits, or the key's monthly cap is reached. Codes:
insufficient_credits,key_monthly_cap. - 404A style or reference that is not yours, or no longer exists. Codes:
style_not_found,reference_not_found. - 413A reference given as a link is too large, or your files are full. Codes:
file_too_large,storage_full. - 415A reference given as a link is not a PNG, JPEG or WebP image. Codes:
unsupported_type. - 422Above
max_credits, or Idempotency-Key reused for a different request. Codes:price_above_max,idempotency_key_reused. - 429Too many requests for this key, or one of your account's caps: credits per day, jobs in progress at once. Codes:
rate_limited,daily_credits,concurrent_jobs. - 503Prices are not available right now, or the model is temporarily off. Codes:
no_price_list,model_paused.