Generic Image Generation
Use /v1/images/generations for nano-banana families and gpt-image-2 image models.
/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
| Operation | Endpoint |
|---|---|
| Image generation (sync) | POST /v1/images/generations |
| Image generation (async submit) | POST /v1/images/generations?async=true |
| Image edit compatible entrypoint | POST /v1/images/edits |
| Poll async task result | GET /v1/tasks/{task_id} |
Supported Models
| Model | Description |
|---|---|
nano-banana | Base nano-banana image generation and editing model. |
nano-banana-2 | nano-banana 2 image generation and editing model with broader resolution and search-enhancement options. |
nano-banana-2-lite | Lightweight nano-banana 2 model for faster or lower-cost image generation and editing. |
nanp-banana-pro | nano-banana pro image generation and editing model. |
gpt-image-2 | GPT Image 2 image generation and editing model. |
Generic Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name, such as nano-banana-2 or gpt-image-2. |
prompt | string | Yes | Image generation or edit prompt. |
images | string[] | No | Reference image URLs or reachable image references. This is the recommended unified field. |
image | string / string[] | No | OpenAI image edit compatible field for single or multiple image inputs. |
image_urls | string[] | No | Reference image field compatible with some upstream formats. |
aspect_ratio | string | No | Output aspect ratio. Suitable for nano-banana families and some gpt-image-2 channels. |
resolution | string | No | Image resolution or billing tier. Suitable for nano-banana families and some gpt-image-2 channels. |
size | string | No | OpenAI/gpt-image compatible size field. Suitable for gpt-image-2. |
quality | string | No | Image quality. Suitable for gpt-image-2; some channels may allow it for other models. |
output_format | string | No | Output format, such as png or jpeg. |
response_format | string | No | OpenAI-compatible response format, such as url or b64_json. |
n | number | No | Number of images. Support depends on the model and channel. |
enable_web_search | boolean | No | Available for nano-banana-2 families to enable web search enhancement. |
enable_image_search | boolean | No | Available 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.
| Field | Recommended values |
|---|---|
images | Reference image array. Omit it for text-to-image; send it for image-to-image or image editing. |
aspect_ratio | 1: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. |
resolution | 0.5k, 1k, 2k, 4k. |
output_format | png, jpeg. |
enable_web_search | true or false, mainly for nano-banana-2 families. |
enable_image_search | true 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.
| Field | Recommended values |
|---|---|
size | OpenAI-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_ratio | Ratio-based channels may use values such as 1:1, 4:3, 16:9, or 9:16. |
resolution | Tier-based channels may use values such as 1k, 2k, or 4k. |
quality | low, medium, high, auto. |
output_format | png, jpeg. |
response_format | Not 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"
}Async Image Generation (Recommended, especially for gpt-image-2)
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 likegpt-image-2, async is strongly recommended to avoid500/504timeouts 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.