⌘K

Google Nano Banana 2.1

nano_banana_2_1

Google Nano Banana 2.1 supports text-to-image generation, image editing, and multi-reference composition with 1K, 2K, and 4K image output and configurable thinking levels.

API Notes

nano_banana_2_1 supports text-to-image generation, image editing, and multi-reference composition through the platform asynchronous generation API

nano_banana_2_1 returns generated image URLs in output[].content[]; generated text and thinking images are not delivered as separate outputs

nano_banana_2_1 accepts either prompt with optional image_urls, or native contents; when contents is supplied, outer prompt and image_urls are ignored, so place all text and reference images inside contents

nano_banana_2_1 does not support tools, toolConfig, cachedContent, previous_interaction_id, response_format, or generation_config; these fields cause the task to fail

nano_banana_2_1 uses a fixed response modality configuration; response_modalities cannot configure image-only or interleaved text output

Authentication

authorization string required

All APIs require authentication via Bearer Token.

Get API Key:

Visit API Key Management Page to get your API Key.

Usage:

Add to request header:

Authorization: Bearer YOUR_API_KEY

Parameters

Send requests to POST https://cloud.vtrix.ai/model/v1/generation. The examples on the right show text-to-image generation, image editing, and two reference images. Replace all example image URLs with publicly accessible image URLs

model string required

Public model identifier, placed at the top level of the request

Value: nano_banana_2_1


input array required

Generation input array. Put the following image generation parameters inside input[0].params


prompt string

Text instructions describing the image to generate or edit. Required when using the simplified request form without contents

Prompt guidelines:

  • Text-to-image: Specify the subject, scene, style, and lighting
  • Image editing: Describe what to change and what to preserve
  • Multiple references: Explain the role of each reference image and how to combine them

image_urls array<string>

Reference image URLs for image editing or multi-reference composition. Use URLs that the platform can download without additional authentication


aspect_ratio string

Output image aspect ratio. If omitted, the model determines the ratio

Examples: 1:1, 16:9


resolution string

Output image resolution

Options: 1K, 2K, 4K

Default: 1K


thinking_level string

Controls the model thinking level. Thinking content is not delivered as a separate output

Options: minimal, medium, high

Default: medium

Advanced Parameters

These parameters also belong inside input[0].params. When using native content entries, put all text and reference images inside contents

contents array<object>

Native content entries for advanced image requests. Each entry contains role and parts; text uses parts[].text, and reference images use parts[].inlineData.mimeType and parts[].inlineData.data. Image data must be Base64-encoded image bytes without a data URI prefix. Include the complete content history when providing multiple turns, and retain thoughtSignature values already available in that history


generationConfig object

Native nested generation settings, including imageConfig.aspectRatio, imageConfig.imageSize, and thinkingConfig.thinkingLevel. If the corresponding convenience fields aspect_ratio, resolution, or thinking_level are also supplied, they take precedence over these nested settings


systemInstruction object

System instructions provided as a parts array with text entries


safetySettings array<object>

Native safety settings containing category and threshold entries. Requests remain subject to model safety checks

Advanced Request Example

This request uses contents instead of outer prompt and image_urls. Replace BASE64_PRODUCT_IMAGE and BASE64_SCENE_IMAGE with the Base64 contents of your PNG reference images

curl --location 'https://cloud.vtrix.ai/model/v1/generation' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
  "model": "nano_banana_2_1",
  "input": [
    {
      "params": {
        "contents": [
          {
            "role": "user",
            "parts": [
              {
                "text": "Place the product from the first image in the scene from the second image"
              },
              {
                "inlineData": {
                  "mimeType": "image/png",
                  "data": "BASE64_PRODUCT_IMAGE"
                }
              },
              {
                "inlineData": {
                  "mimeType": "image/png",
                  "data": "BASE64_SCENE_IMAGE"
                }
              }
            ]
          }
        ],
        "systemInstruction": {
          "parts": [
            {
              "text": "Preserve the product shape and logo."
            }
          ]
        },
        "generationConfig": {
          "imageConfig": {
            "aspectRatio": "16:9",
            "imageSize": "2K"
          },
          "thinkingConfig": {
            "thinkingLevel": "high"
          }
        }
      }
    }
  ]
}'

Polling

Since result generation takes time, you need to poll the task status after creating the task.

The initial response only returns information such as the task ID and initial status. The final result must be obtained by polling the task status endpoint using the task ID.

See the examples on the right for polling requests and responses.

Query GET https://cloud.vtrix.ai/model/v1/generation/task/{task_id} using the id returned by creation. The status: "completed" in the creation receipt confirms acceptance only; it does not mean that the image is ready. The same task may subsequently be in_progress when queried

Continue querying while the task is processing. Read output only from a completed query response; stop polling on failed and inspect error. Reuse the same task ID when checking status instead of submitting another generation request

Query statusAction
in_queueWait and query again
in_progressWait and query again
completedRead generated images from output[].content[]
failedStop polling and read error.code and error.message

Response Format

The right-side examples illustrate the creation receipt, a processing query response, and a successful query response. IDs, URLs, and usage values are illustrative; response examples show a subset of fields

FieldTypeDescription
idstringTask ID used for subsequent queries
created_atintegerCreation timestamp in milliseconds
statusstringTask status; interpret creation receipts as described in Polling
modelstringPublic model identifier
request_idstringRequest correlation ID, when present
outputarrayGenerated resources in successful query responses
output[].content[].typestringimage
output[].content[].urlstringDownload URL for the generated image
output[].content[].mime_typestringActual image MIME type, such as image/png or image/jpeg
errorobjectFailure details; may be null on a successful creation receipt
error.codestringError code
error.messagestringError description
usageobjectUsage information, when available
metadataobjectAdditional task timing information, when present

Token Usage

Gemini usage fields and usage.extra_info describe the measured usage. Do not assume generic prompt_tokens, completion_tokens, or total_tokens fields are populated. Optional usage fields may be omitted when their value is zero or no detail is available

Field under usageDescription
promptTokenCountTotal measured input tokens
promptTokensDetailsInput token details by modality; entries contain modality and tokenCount
candidatesTokenCountCandidate output tokens, excluding separately reported thinking tokens
candidatesTokensDetailsCandidate token details by modality
thoughtsTokenCountSeparately reported thinking tokens
totalTokenCountTotal reported token usage
extra_info.input_text_tokensText input tokens, including unclassified input tokens
extra_info.input_image_tokensReference image input tokens
extra_info.output_text_tokensCandidate text tokens, unclassified candidate tokens, and thinking tokens combined
extra_info.output_image_tokensGenerated image output tokens
extra_info.thoughts_tokensThinking token breakdown, already included in output_text_tokens
extra_info.num_imagesNumber of delivered final images
costRequest cost in USD

These usage fields are read from the response and do not need to be supplied in the request

Error Codes

A task can be accepted and fail later during processing. The failure response uses string error codes; the message depends on the specific failure

{
  "id": "mmsu_example_task_id",
  "created_at": 1791763200000,
  "status": "failed",
  "model": "nano_banana_2_1",
  "error": {
    "code": "RUNTIME_CREATE_PREPARE_FAILED",
    "message": "Unsupported request field: tools"
  }
}
Error codeDescription
RUNTIME_CREATE_PREPARE_FAILEDRequest preparation failed, for example because an unsupported field was supplied
RUNTIME_CREATE_PROVIDER_FAILEDModel execution failed, for example because the requested resolution was invalid