From 7d897106e3347fa647fcf495b104fb6d99d79488 Mon Sep 17 00:00:00 2001 From: liyb Date: Fri, 9 Oct 2026 07:56:36 +0800 Subject: [PATCH] docs(native-api): add Nano Banana 2.1 native page and image token billing --- .vitepress/theme/OfficialNativeApiSidebar.vue | 4 + api-reference/gemini-generate-content.md | 1 + .../google/gemini-3-pro-image.md | 14 ++ .../google/gemini-3.1-flash-image.md | 14 ++ .../google/gemini-nano-banana-2.1.md | 147 ++++++++++++++++++ .../official-native-api/index.md | 1 + 6 files changed, 181 insertions(+) create mode 100644 model-api-reference/official-native-api/google/gemini-nano-banana-2.1.md diff --git a/.vitepress/theme/OfficialNativeApiSidebar.vue b/.vitepress/theme/OfficialNativeApiSidebar.vue index b84f1fe6..df40c454 100644 --- a/.vitepress/theme/OfficialNativeApiSidebar.vue +++ b/.vitepress/theme/OfficialNativeApiSidebar.vue @@ -56,6 +56,10 @@ const googleModels = [ text: 'Gemini 3.1 Flash Image(Nano Banana 2)', link: '/model-api-reference/official-native-api/google/gemini-3.1-flash-image', }, + { + text: 'Gemini Nano Banana 2.1(Nano Banana 2.1)', + link: '/model-api-reference/official-native-api/google/gemini-nano-banana-2.1', + }, ] function normalize(path: string) { diff --git a/api-reference/gemini-generate-content.md b/api-reference/gemini-generate-content.md index 85e21b39..ee7c2674 100644 --- a/api-reference/gemini-generate-content.md +++ b/api-reference/gemini-generate-content.md @@ -77,6 +77,7 @@ These image models have dedicated native GenerateContent mappings: - [Gemini 3 Pro Image(Nano Banana Pro)](/model-api-reference/official-native-api/google/gemini-3-pro-image) - [Gemini 3.1 Flash Image(Nano Banana 2)](/model-api-reference/official-native-api/google/gemini-3.1-flash-image) +- [Gemini Nano Banana 2.1(Nano Banana 2.1)](/model-api-reference/official-native-api/google/gemini-nano-banana-2.1) For these mappings, SandBase forwards the request and response payloads without converting them through Chat Completions. This preserves image parts, response modalities, and provider-defined fields. Use the bare model name in diff --git a/model-api-reference/official-native-api/google/gemini-3-pro-image.md b/model-api-reference/official-native-api/google/gemini-3-pro-image.md index 6556ce73..75e0ef76 100644 --- a/model-api-reference/official-native-api/google/gemini-3-pro-image.md +++ b/model-api-reference/official-native-api/google/gemini-3-pro-image.md @@ -83,6 +83,20 @@ Add the source image as an `inlineData` part next to the text instruction. Use t } ``` +## Billing + +Usage is billed per token at Google's standard list price: + +| Token type | Price (USD / 1M tokens) | +|---|---| +| Input (text and image) | $2.00 | +| Output text and thinking | $12.00 | +| Output image | $120.00 | + +One output image uses 1120 tokens at 1K and 2K and 2000 tokens at 4K, about $0.134 and $0.24 per image. Image tokens +are taken from `usageMetadata.candidatesTokensDetails` (`modality: IMAGE`); the remaining output tokens are billed at +the text rate. + ## Response handling Read generated media from the returned candidate parts. Because this model uses native passthrough, provider-defined diff --git a/model-api-reference/official-native-api/google/gemini-3.1-flash-image.md b/model-api-reference/official-native-api/google/gemini-3.1-flash-image.md index b7a4157b..f60dd0e3 100644 --- a/model-api-reference/official-native-api/google/gemini-3.1-flash-image.md +++ b/model-api-reference/official-native-api/google/gemini-3.1-flash-image.md @@ -82,6 +82,20 @@ Add the source image as an `inlineData` part next to the text instruction. Use t } ``` +## Billing + +Usage is billed per token at Google's standard list price: + +| Token type | Price (USD / 1M tokens) | +|---|---| +| Input (text and image) | $0.50 | +| Output text and thinking | $3.00 | +| Output image | $60.00 | + +One output image uses 747 tokens at 0.5K, 1120 at 1K, 1680 at 2K and 2520 at 4K, about $0.045, $0.067, $0.101 and +$0.151 per image. Image tokens are taken from `usageMetadata.candidatesTokensDetails` (`modality: IMAGE`); the +remaining output tokens are billed at the text rate. + ## Response handling Read generated media from the returned candidate parts. Because this model uses native passthrough, provider-defined diff --git a/model-api-reference/official-native-api/google/gemini-nano-banana-2.1.md b/model-api-reference/official-native-api/google/gemini-nano-banana-2.1.md new file mode 100644 index 00000000..976fb70d --- /dev/null +++ b/model-api-reference/official-native-api/google/gemini-nano-banana-2.1.md @@ -0,0 +1,147 @@ +--- +title: "Gemini Nano Banana 2.1(Nano Banana 2.1)Native API Reference" +description: "Native Gemini GenerateContent API reference for google/gemini-nano-banana-2.1 (Nano Banana 2.1) on SandBase." +aside: false +outline: false +apiReference: + title: Gemini Nano Banana 2.1(Nano Banana 2.1) + operation: Gemini GenerateContent + method: POST + path: /v1beta/models/gemini-nano-banana-2.1:generateContent + description: Generate or edit images with Nano Banana 2.1 through the native Google Gemini protocol. SandBase preserves the provider request and response payload instead of converting it to Chat Completions. + groups: + - title: Request body + description: Send a native Gemini GenerateContent body. Provider-defined fields are passed through for this model. + fields: + - { name: contents, type: array, required: true, description: Gemini Content objects containing the prompt and optional input images. } + - { name: generationConfig.responseModalities, type: "array", required: true, description: "Requested output modalities. Include IMAGE; include TEXT when you also want a text part." } + - { name: generationConfig.imageConfig.aspectRatio, type: string, required: false, description: "Output aspect ratio, for example 1:1, 16:9, 9:16, 21:9, 4:1 or 1:8." } + - { name: generationConfig.imageConfig.imageSize, type: string, required: false, description: "Output resolution: 1K, 2K or 4K. Nano Banana 2.1 has no 0.5K tier." } + examples: + - label: cURL + language: bash + code: |- + curl -X POST \ + "https://api.sandbase.ai/v1beta/models/gemini-nano-banana-2.1:generateContent" \ + -H "x-goog-api-key: $SANDBASE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "contents": [{ + "role": "user", + "parts": [{"text": "Create a wide editorial illustration of a solar-powered city at sunrise."}] + }], + "generationConfig": { + "responseModalities": ["IMAGE"], + "imageConfig": {"aspectRatio": "16:9", "imageSize": "1K"} + } + }' + response: + status: 200 OK + code: |- + { + "candidates": [{ + "content": { + "role": "model", + "parts": [ + {"inlineData": {"mimeType": "image/jpeg", "data": ""}, "thoughtSignature": ""} + ] + }, + "finishReason": "STOP", + "index": 0 + }], + "usageMetadata": { + "promptTokenCount": 14, + "candidatesTokenCount": 1120, + "candidatesTokensDetails": [{"modality": "IMAGE", "tokenCount": 1120}], + "totalTokenCount": 1134 + } + } +seo: + modelName: "Gemini Nano Banana 2.1(Nano Banana 2.1)" + modelId: "google/gemini-nano-banana-2.1" + vendor: "Google" + vendorSlug: "google" + modelSlug: "gemini-nano-banana-2.1" + protocol: "Gemini GenerateContent API" + endpoint: "/v1beta/models/gemini-nano-banana-2.1:generateContent" + publishedAt: "2026-10-08T00:00:00Z" + capabilities: ["image_generation", "image_editing"] + category: "Official Native API" +--- + + + +## Edit an image + +Add the source image as an `inlineData` part next to the text instruction. Use the MIME type of the bytes you send: + +```json +{ + "contents": [{ + "role": "user", + "parts": [ + {"text": "Keep the subject unchanged and turn the background into a paper-cut landscape."}, + {"inlineData": {"mimeType": "image/png", "data": ""}} + ] + }], + "generationConfig": {"responseModalities": ["IMAGE"], "imageConfig": {"imageSize": "1K"}} +} +``` + +## Use the Google Gen AI SDK + +Point the official SDK at SandBase and use your SandBase API key: + +```python +from google import genai +from google.genai import types + +client = genai.Client( + api_key="YOUR_SANDBASE_API_KEY", + http_options=types.HttpOptions(base_url="https://api.sandbase.ai"), +) + +response = client.models.generate_content( + model="gemini-nano-banana-2.1", + contents="Create a wide editorial illustration of a solar-powered city at sunrise.", + config=types.GenerateContentConfig( + response_modalities=["IMAGE"], + image_config=types.ImageConfig(aspect_ratio="16:9", image_size="1K"), + ), +) + +for part in response.candidates[0].content.parts: + if part.inline_data: + with open("output.jpg", "wb") as f: + f.write(part.inline_data.data) +``` + +For streaming, call `:streamGenerateContent?alt=sse` (SDK: `generate_content_stream`) with the same body. + +## Billing + +Usage is billed per token at Google's standard list price: + +| Token type | Price (USD / 1M tokens) | +|---|---| +| Input (text and image) | $1.50 | +| Output text and thinking | $7.50 | +| Output image | $30.00 | + +One output image uses 1120 tokens at 1K, 1680 at 2K and 3780 at 4K, about $0.034, $0.050 and $0.113 per image. +Image tokens are taken from `usageMetadata.candidatesTokensDetails` (`modality: IMAGE`); the remaining output tokens are +billed at the text rate. + +## Response handling + +Read generated media from the returned candidate parts. Because this model uses native passthrough, provider-defined +field casing and MIME metadata are returned as received. The output is usually JPEG; decode the base64 payload and +verify the actual media bytes before choosing a file extension. Keep `thoughtSignature` when you send the turn back in +multi-turn editing. + +## Official Google resources + +- [Gemini API documentation](https://ai.google.dev/gemini-api/docs) +- [Image generation documentation](https://ai.google.dev/gemini-api/docs/image-generation) +- [GenerateContent API reference](https://ai.google.dev/api/generate-content) +- [Gemini API pricing](https://ai.google.dev/gemini-api/docs/pricing) diff --git a/model-api-reference/official-native-api/index.md b/model-api-reference/official-native-api/index.md index a9ca25f9..d5385f6d 100644 --- a/model-api-reference/official-native-api/index.md +++ b/model-api-reference/official-native-api/index.md @@ -30,6 +30,7 @@ GPT Image models use the native OpenAI Images API at `/v1/images/generations` an - [Gemini Omni 1.1 Flash Preview](/model-api-reference/official-native-api/google/gemini-omni-1.1-flash-preview) - [Gemini 3 Pro Image(Nano Banana Pro)](/model-api-reference/official-native-api/google/gemini-3-pro-image) - [Gemini 3.1 Flash Image(Nano Banana 2)](/model-api-reference/official-native-api/google/gemini-3.1-flash-image) +- [Gemini Nano Banana 2.1(Nano Banana 2.1)](/model-api-reference/official-native-api/google/gemini-nano-banana-2.1) Gemini Omni models use the native Google Gemini Interactions protocol at `/v1beta/interactions`. The two image models use Google GenerateContent at `/v1beta/models/{model}:generateContent`; their native request and response payloads are