TokenRa
中文Get API Key

Image model · Google

Nano Banana Pro API

Nano Banana Pro is Google's Gemini 3 Pro Image model, served on TokenRa under the ID gemini-3-pro-image-preview. One chat message generates or edits an image, and the Gemini generateContent format works too. Requests are synchronous: each test returned a JPEG in 36–84 seconds.

Model ID
gemini-3-pro-image-preview
Input
Text, image (edits)
Output
JPEG, 1K to 4K
Billing
Per request
For AI agents
llms.txt guide

Capabilities

Capabilities & endpoints

Both endpoints were called successfully on 2026-11-22, and the OpenAI SDKs work with base_url=https://tokenra.io/v1. The image endpoints /v1/images/generations and /v1/images/edits do not serve this model.

POSThttps://tokenra.io/v1/chat/completionsTested
OpenAI Chat Completions. A text prompt generates an image; a text part plus an image_url part edits one. The image comes back in choices[0].message.content.
POSThttps://tokenra.io/v1beta/models/gemini-3-pro-image-preview:generateContentTested
Google Gemini format. Set the aspect ratio and size in generationConfig.imageConfig; the image comes back as inlineData.

Request

Request parameters

Chat Completions: POST /v1/chat/completions

ParameterTypeRequiredDescription
modelstringYesModel ID: gemini-3-pro-image-preview.
messagesarrayYesOne user message. To generate, its content is the prompt. To edit, its content is an array with a text part and an image_url part whose url is a base64 data URL (tested with a JPEG).
extra_body.google.image_config.aspect_ratiostringNoOutput aspect ratio, such as 1:1, 16:9 or 9:16. Without it the model chooses: the tests returned 1376×768 and 1408×768.
extra_body.google.image_config.image_sizestringNo1K (default), 2K or 4K. 4K with 1:1 returned 4096×4096.

Write the image_config keys in snake_case: aspectRatio or imageSize there is rejected with HTTP 500 convert_request_failed. With the OpenAI Python SDK, pass extra_body={"extra_body": {"google": …}}: the SDK merges its extra_body argument into the JSON body, and the gateway reads the extra_body field from there.

Gemini format: POST /v1beta/models/gemini-3-pro-image-preview:generateContent

ParameterTypeRequiredDescription
contentsarrayYesThe prompt: [{"role": "user", "parts": [{"text": "…"}]}].
generationConfig.responseModalitiesarrayNo["IMAGE"] returns the image only (tested).
generationConfig.imageConfig.aspectRatiostringNoAspect ratio, same values as above. 16:9 was tested.
generationConfig.imageConfig.imageSizestringNo1K, 2K or 4K. 2K with 16:9 returned 2752×1536.

Response

Response format

Chat Completions

Example response (base64 shortened)
{
  "id": "chatcmpl-202611220420419771128118268d9d6pZBYtojk",
  "object": "chat.completion",
  "created": 1795321277,
  "model": "gemini-3-pro-image-preview",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "![image](data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEs...)"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 1250,
    "total_tokens": 1268,
    "completion_tokens_details": {"image_tokens": 1120, "reasoning_tokens": 130}
  }
}
FieldTypeDescription
choices[].message.contentstringA Markdown image: ![image](data:image/jpeg;base64,…). Decode the part after base64, to get the JPEG.
usage.completion_tokens_details.image_tokensintegerImage tokens reported by the model: 1120 for 1K and 2K, 2000 for 4K in testing. Billing is per request, not per token.
usage.completion_tokens_details.reasoning_tokensintegerThe model plans before drawing (109–191 tokens in testing); no reasoning text is returned.

Gemini format

Example response (base64 shortened)
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "inlineData": {"mimeType": "image/jpeg", "data": "/9j/4AAQSkZJRgABAQEBLAEs..."},
            "thoughtSignature": "+ohstAcrEvsgQfXmYQz0ZPIp..."
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 14,
    "candidatesTokenCount": 1120,
    "thoughtsTokenCount": 43,
    "totalTokenCount": 1177
  },
  "modelVersion": "gemini-3-pro-image-preview"
}
FieldTypeDescription
candidates[].content.parts[].inlineData.datastringBase64 JPEG. Decode and save it.
candidates[].content.parts[].inlineData.mimeTypestringimage/jpeg in every test.
usageMetadataobjectToken counts reported by the model.

Errors

Errors & limits

Common errors

HTTPerror.codeMeaningWhat to do
401—Missing, wrong or deleted API key. The message is Invalid token.Check the Authorization: Bearer header and the key in the console.
400—The body is not valid JSON.Fix the JSON and send Content-Type: application/json.
500invalid_requestA required field is missing, for example messages.Add the field named in the message. Retrying will not help.
403insufficient_user_quotaYour balance or plan quota is used up.Top up in the console, then retry.
503model_not_foundUnknown model ID, or no channel serves it for your group.Check the ID in the model list or with GET /v1/models.
429—Too many requests.Back off exponentially and retry.
5xx—The upstream provider failed or timed out.Retry a few times; keep the request id if it persists.

Limits and notes

  • Each request took 36–84 seconds in testing; 2K and 4K were the slowest. Set the client timeout to at least 180 seconds.
  • Output is JPEG and the size depends on the resolution and on how detailed the picture is: 0.1–0.4 MB without image_size, 1.6–4.3 MB at 2K and 3.4–12.9 MB at 4K (4096×4096) in testing. Base64 adds a third, so a 4K response can exceed 17 MB of JSON. An edit request carries the source image as base64 too: a 2K source made a 4.4 MB request.
  • Billing is per request at the same rate for 1K, 2K and 4K output and for edits. Failed requests were not charged. See the live rate in the Model Square.
  • /v1/images/generations and /v1/images/edits return HTTP 500 convert_request_failed ("only imagen models are supported") for this model. Use one of the two endpoints above.