Nano Banana 2.1 — OpenAI Images
Overview
Use nano-banana-2.1 to generate an image from text or edit up to 14 reference images. Each synchronous request returns one image URL. This format suits OpenAI Images clients and integrations that supply reference images as URLs.
Endpoints
| Workflow | Method and path | Input |
|---|---|---|
| Text to image | POST /v1/images/generations | A non-empty prompt. |
| Image editing | POST /v1/images/edits | A non-empty prompt and at least one reference image. |
The base URL is https://api.uniall.ai. Nano Banana 2.1 does not support /v1/chat/completions or /v1/images/tasks.
Authentication
Use your UniAI user API key:
Authorization: Bearer <UNIAI_API_KEY>
Content-Type: application/json
Request Parameters
Place the main parameters at the top level of the JSON body.
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | nano-banana-2.1. |
prompt | string | Yes | Non-empty generation or editing instruction. |
resolution | string | No | 1k, 2k, or 4k; defaults to 1k. Uppercase values are also accepted. |
aspect_ratio | string | No | One of the 14 ratios below. If omitted, the ratio follows the reference image or generated content. |
thinking_level | string | No | minimal, medium, or high; defaults to medium. |
images | string[] | Conditional | Preferred reference-image field for editing. HTTP(S) URLs or complete image Data URLs. |
image / image_url | string | Conditional | Alternative reference-image fields. HTTP(S) URL or complete image Data URL. |
image_urls | string[] | Conditional | Alternative array of reference-image URLs or complete image Data URLs. |
n | integer | No | Only 1 is accepted; each request returns one image. |
num_images | integer | No | Compatible image-count field; only 1 is accepted. |
response_format | string | No | Accepts url or b64_json for compatibility. This endpoint always returns a URL. |
output_format | string | No | Accepts png or jpeg for compatibility. The actual format follows the result; conversion is not guaranteed. |
Resolution And Aspect Ratio
Supported aspect ratios:
1: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
Resolution is a tier, not a fixed longest-edge pixel count. For example, a non-square 1k result can be 1376 × 768. 0.5K, 512, and 8K are unsupported.
Reference Images And Compatibility Fields
Editing requires 1 to 14 reference images across all reference fields combined. PNG, JPEG, and WebP are supported. Input order and duplicate entries are preserved; duplicates count toward the 14-image limit. Reference URLs must be directly accessible to the service. A Data URL must include the image MIME type and Base64 prefix, such as data:image/png;base64,....
Use JSON references for editing. Multipart file uploads are unsupported.
resolution, thinking_level, num_images, output_format, and response_format may also be placed in extra_body for compatibility. If a field appears both at the top level and in extra_body, its values must match. The examples use top-level parameters.
Request Examples
Text To Image
curl -X POST "https://api.uniall.ai/v1/images/generations" \
-H "Authorization: Bearer <UNIAI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2.1",
"prompt": "Create a spring latte poster with a cream background and clear typography",
"resolution": "2k",
"aspect_ratio": "16:9",
"thinking_level": "high",
"n": 1
}'
Image Editing
curl -X POST "https://api.uniall.ai/v1/images/edits" \
-H "Authorization: Bearer <UNIAI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2.1",
"prompt": "Keep the cup shape and color; replace the background with a bright cafe",
"images": ["https://example.com/reference.png"],
"resolution": "2k",
"aspect_ratio": "4:5",
"thinking_level": "medium",
"n": 1
}'
Replace the example URL with your reference image. Add references to images in the order described by your prompt.
Response Example
{
"created": 1791676800,
"data": [
{
"url": "https://example.com/generated.png"
}
]
}
Read data[0].url from the completed response. Even if you send response_format: "b64_json", this entry point returns a URL. Inspect the downloaded file to determine its actual image format.
The response is synchronous and has no task ID or polling step. A client timeout does not confirm that generation stopped; avoid automatically submitting the request again.
Capability Limits And Common Errors
- Search is unavailable. Omit
tools,enable_web_search, andenable_image_search; supplying them is rejected even when a search flag isfalse. quality, custom pixel dimensions throughsizeorcustom_size, masks, transparent backgrounds,seed, and streaming output are unsupported.- An editing request without a reference image, more than 14 references, an unsupported resolution or aspect ratio, or a count other than
1is invalid. - Keep OpenAI field names in this request. Gemini
contentsandgenerationConfigbelong to the Gemini page. thinking_levelis available only for the new 2.1 integration. It is not enabled fornano-banana-2,nano-banana-pro, or fixed-resolution compatibility models.