Models Hub
API ReferenceImages

Generic Image Generation

Use /v1/images/generations for nano-banana families and gpt-image-2 image models.

Edit this page

/v1/images/generations is the recommended generic image entrypoint in Models Hub. For text-to-image, send model and prompt. For reference-image generation or image editing, also send images, image, or image_urls.

Supported parameters are not identical across models. Keep the unified entrypoint, but choose fields and values according to the requested model.

Endpoints

OperationEndpoint
Image generation (sync)POST /v1/images/generations
Image generation (async submit)POST /v1/images/generations?async=true
Image edit compatible entrypointPOST /v1/images/edits
Poll async task resultGET /v1/tasks/{task_id}

Supported Models

ModelDescription
nano-bananaBase nano-banana image generation and editing model.
nano-banana-2nano-banana 2 image generation and editing model with broader resolution and search-enhancement options.
nano-banana-2-liteLightweight nano-banana 2 model for faster or lower-cost image generation and editing.
nanp-banana-pronano-banana pro image generation and editing model.
gpt-image-2GPT Image 2 image generation and editing model.

Generic Request Fields

FieldTypeRequiredDescription
modelstringYesModel name, such as nano-banana-2 or gpt-image-2.
promptstringYesImage generation or edit prompt.
imagesstring[]NoReference image URLs or reachable image references. This is the recommended unified field.
imagestring / string[]NoOpenAI image edit compatible field for single or multiple image inputs.
image_urlsstring[]NoReference image field compatible with some upstream formats.
aspect_ratiostringNoOutput aspect ratio. Suitable for nano-banana families and some gpt-image-2 channels.
resolutionstringNoImage resolution or billing tier. Suitable for nano-banana families and some gpt-image-2 channels.
sizestringNoOpenAI/gpt-image compatible size field. Suitable for gpt-image-2.
qualitystringNoImage quality. Suitable for gpt-image-2; some channels may allow it for other models.
output_formatstringNoOutput format, such as png or jpeg.
response_formatstringNoOpenAI-compatible response format, such as url or b64_json.
nnumberNoNumber of images. Support depends on the model and channel.
enable_web_searchbooleanNoAvailable for nano-banana-2 families to enable web search enhancement.
enable_image_searchbooleanNoAvailable for nano-banana-2 families to enable image search enhancement.

Model-Specific Parameters

nano-banana Families

The nano-banana family includes nano-banana, nano-banana-2, nano-banana-2-lite, and nanp-banana-pro. Prefer images, aspect_ratio, resolution, and output_format.

FieldRecommended values
imagesReference image array. Omit it for text-to-image; send it for image-to-image or image editing.
aspect_ratio1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1.
resolution0.5k, 1k, 2k, 4k.
output_formatpng, jpeg.
enable_web_searchtrue or false, mainly for nano-banana-2 families.
enable_image_searchtrue or false, mainly for nano-banana-2 families.
{
  "model": "nano-banana-2",
  "prompt": "Replace the item in the poster with a cup",
  "images": [
    "https://example.com/input.png"
  ],
  "aspect_ratio": "4:3",
  "resolution": "2k",
  "output_format": "png",
  "enable_web_search": false,
  "enable_image_search": false
}

gpt-image-2

gpt-image-2 may use either OpenAI-compatible size parameters or tiered image parameters, depending on the active channel. Do not treat size and the nano-banana resolution tier as the same semantic field. See the Image Generation Guide for the full size rules and quality tiers.

FieldRecommended values
sizeOpenAI-compatible sizes such as 1024x1024, 1536x1024, 2048x2048, 3840x2160. Width and height must be multiples of 16, total pixels 655,360–8,294,400, longest edge ≤3840; the output matches it exactly.
aspect_ratioRatio-based channels may use values such as 1:1, 4:3, 16:9, or 9:16.
resolutionTier-based channels may use values such as 1k, 2k, or 4k.
qualitylow, medium, high, auto.
output_formatpng, jpeg.
response_formatNot supported — sending it returns 400 Unknown parameter. Results are always returned as b64_json.
{
  "model": "gpt-image-2",
  "prompt": "A cinematic product photo of a ceramic cup",
  "size": "1536x1024",
  "quality": "high"
}

If the active channel uses ratio and tier fields, call it like this:

{
  "model": "gpt-image-2",
  "prompt": "A cinematic product photo of a ceramic cup",
  "aspect_ratio": "4:3",
  "resolution": "2k",
  "quality": "high",
  "output_format": "png"
}

Models such as gpt-image-2 can take a while to render synchronously (commonly 30 seconds to over 2 minutes). A synchronous call holds the connection open the whole time, so upstream jitter or a gateway/CDN timeout can surface as 500 (upstream failure passed through) or 504 (gateway timeout).

Prefer async: add the ?async=true query parameter to POST /v1/images/generations. The gateway returns a task object (with an id) immediately; you then poll the task result at a fixed interval until it succeeds. Each request stays short, avoiding long-connection timeouts entirely.

1. Submit asynchronously

curl "$MODELSOK_BASE_URL/v1/images/generations?async=true" \
  -H "Authorization: Bearer $MODELSOK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A cinematic product photo of a ceramic cup",
    "size": "1024x1024"
  }'

The response returns an async task object immediately; keep its id:

{
  "id": "task_xxx",
  "object": "image.task",
  "created": 1770000000,
  "model": "gpt-image-2",
  "status": "created"
}

2. Poll the task result

Call the query endpoint with the id from the previous step, polling every 3–5 seconds:

curl "$MODELSOK_BASE_URL/v1/tasks/task_xxx" \
  -H "Authorization: Bearer $MODELSOK_API_KEY"

When the task succeeds, the result contains the final image (url or b64_json, depending on response_format). If it fails, read the error and retry as needed.

Note: Synchronous calls (without ?async=true) still work and suit fast models such as the nano-banana family. For slow models like gpt-image-2, async is strongly recommended to avoid 500 / 504 timeouts on the synchronous long connection.

Image Editing

For reference-image input, prefer the images array. image also works for single-image input, but images is clearer for multi-image editing.

{
  "model": "nano-banana-2",
  "prompt": "Replace the main object in the reference poster with a cup",
  "images": [
    "https://example.com/poster.png"
  ],
  "aspect_ratio": "4:3",
  "resolution": "2k"
}

Response

Some image models return an async task ID:

{
  "id": "task_xxx",
  "object": "image.task",
  "created": 1770000000,
  "model": "nano-banana-2",
  "status": "created"
}

After the task completes, poll GET /v1/tasks/{task_id} for the final image URL (see "Async Image Generation" above). Whether the call waits synchronously and returns the OpenAI image format depends on whether the request includes ?async=true, plus the active model and channel configuration.

On this page