> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiekou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Nano Banana

Parameters and usage are aligned with the official implementation. For detailed parameters, refer directly to the official documentation.

## How to Call

* `https://{api_domain}/gemini/v1/models/{model}:generateContent`
* `https://{api_domain}/gemini/v1beta/models/{model}:generateContent`

BaseURL:

* `https://{api_domain}/gemini`

## Supported Models

* `gemini-3.1-flash-lite-image`
* `gemini-3.1-flash-image`
* `gemini-3-pro-image`
* `gemini-2.5-flash-image`
* `gemini-3.1-flash-lite-image-as`
* `gemini-3.1-flash-image-as`
* `gemini-3-pro-image-as`
* `gemini-2.5-flash-image-as`

## REST API

Request example (for detailed API usage, refer to the official documentation at [https://ai.google.dev/gemini-api/docs/image-generation](https://ai.google.dev/gemini-api/docs/image-generation))

### Text-to-Image

```bash theme={null}
curl -X POST 'https://{api_domain}/gemini/v1/models/gemini-2.5-flash-image:generateContent' \
    -H 'Authorization: Bearer apikey' \
    -H 'Content-Type: application/json' \
    -d '{
      "contents": [{
        "role": "user",
        "parts": [{"text": "Generate an image of a cute cat playing with yarn"}]
      }],
      "generationConfig": {
        "responseModalities": ["IMAGE"]
      }
    }'
```

### Image Editing

```bash theme={null}
curl -X POST 'https://{api_domain}/gemini/v1/models/gemini-3-pro-image:generateContent' \
    -H 'Authorization: Bearer apikey' \
    -H 'Content-Type: application/json' \
    -d '{
      "contents": [{
        "role": "user",
        "parts": [
          {"text": "Add a party hat to this cat"},
          {
            "inlineData": {
              "mimeType": "image/jpeg",
              "data": "'"$(cat /path/to/image | base64 -w0)"'"
            }
          }
        ]
      }],
      "generationConfig": {
        "responseModalities": ["TEXT", "IMAGE"],
        "imageConfig": {
            "aspectRatio": "16:9",
            "imageSize": "2K"
        }
      }
    }'
```

## GenAI SDK

```python theme={null}
from google import genai
from google.genai import types

api_key = "{your-api-key}"

client = genai.Client(
    http_options=types.HttpOptions(
        base_url=f"https://{api_domain}/gemini",
        api_version="v1",
        headers={
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json",
        },
    ),
    api_key=api_key,
)

try:
    response = client.models.generate_content(
        model="gemini-2.5-flash-image",
        contents="Generate an image of a cute cat playing with yarn",
        config=types.GenerateContentConfig(
            response_modalities=["IMAGE"],
        ),
    )
except Exception as e:
    print(f"API request failed: {e}")
    exit(1)

# Extract the generated image
if not response.candidates:
    print("No candidates returned in the response.")
    exit(1)

for part in response.candidates[0].content.parts:
    if part.inline_data:
        try:
            data = part.inline_data.data
            if isinstance(data, str):
                import base64
                data = base64.b64decode(data)
            with open("output.png", "wb") as f:
                f.write(data)
            print("Image saved to output.png")
        except (OSError, base64.binascii.Error) as e:
            print(f"Failed to save image: {e}")
    elif part.text:
        print(part.text)
```

## Best Practices

### Thinking Draft Image Issue

* With the default parameter `responseModalities=["TEXT", "IMAGE"]`, image generation may probabilistically produce 2 images: one 1k thinking draft image and one final image. The thinking draft image is billed as thinking output tokens, while the final image is billed as final output tokens.
* You need to set `responseModalities = ["IMAGE"]` so that only the final image is generated.
