Skip to main content

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​

WorkflowMethod and pathInput
Text to imagePOST /v1/images/generationsA non-empty prompt.
Image editingPOST /v1/images/editsA 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.

ParameterTypeRequiredDescription
modelstringYesnano-banana-2.1.
promptstringYesNon-empty generation or editing instruction.
resolutionstringNo1k, 2k, or 4k; defaults to 1k. Uppercase values are also accepted.
aspect_ratiostringNoOne of the 14 ratios below. If omitted, the ratio follows the reference image or generated content.
thinking_levelstringNominimal, medium, or high; defaults to medium.
imagesstring[]ConditionalPreferred reference-image field for editing. HTTP(S) URLs or complete image Data URLs.
image / image_urlstringConditionalAlternative reference-image fields. HTTP(S) URL or complete image Data URL.
image_urlsstring[]ConditionalAlternative array of reference-image URLs or complete image Data URLs.
nintegerNoOnly 1 is accepted; each request returns one image.
num_imagesintegerNoCompatible image-count field; only 1 is accepted.
response_formatstringNoAccepts url or b64_json for compatibility. This endpoint always returns a URL.
output_formatstringNoAccepts 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, and enable_image_search; supplying them is rejected even when a search flag is false.
  • quality, custom pixel dimensions through size or custom_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 1 is invalid.
  • Keep OpenAI field names in this request. Gemini contents and generationConfig belong to the Gemini page.
  • thinking_level is available only for the new 2.1 integration. It is not enabled for nano-banana-2, nano-banana-pro, or fixed-resolution compatibility models.