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

# Nano Banana Image Generation

> Generate and edit images with Gemini Nano Banana multimodal models

For authentication, see [Overview](/api-reference/gemini/overview).

## What is Nano Banana

Nano Banana is Gemini's **multimodal image generation capability**, using the same `generateContent` endpoint as text models.

| Model               | Model ID                     | Features                                                                                       |
| ------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------- |
| **Nano Banana**     | `gemini-2.5-flash-image`     | Speed optimized for high-volume tasks                                                          |
| **Nano Banana Pro** | `gemini-3-pro-image-preview` | Professional production, advanced reasoning, high-fidelity text rendering, up to 4K resolution |

## Endpoints

Same as text models:

| Type          | Endpoint                                            |
| ------------- | --------------------------------------------------- |
| Non-Streaming | `POST /v1beta/models/{model}:generateContent`       |
| Streaming     | `POST /v1beta/models/{model}:streamGenerateContent` |

## Text to Image

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -s -X POST \
      "https://api.pipellm.ai/v1beta/models/gemini-3-pro-image-preview:streamGenerateContent" \
      -H "x-goog-api-key: $PIPELLM_API_KEY" \
      -H "Content-Type: application/json" \
      -d @- << 'EOF'
    {
      "contents": [{
        "role": "user",
        "parts": [
          {"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
        ]
      }]
    }
    EOF
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from google import genai
    from PIL import Image

    client = genai.Client(
    api_key=os.getenv('PIPELLM_API_KEY'),
    http_options={'base_url': 'https://api.pipellm.ai'}
    )

    response = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents=["Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"],
    )

    for part in response.parts:
    if part.text is not None:
    print(part.text)
    elif part.inline_data is not None:
    image = part.as_image()
    image.save("generated_image.png")

    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";

    const ai = new GoogleGenAI({
      apiKey: process.env.PIPELLM_API_KEY,
      httpOptions: { baseUrl: 'https://api.pipellm.ai' }
    });

    const response = await ai.models.generateContent({
      model: "gemini-2.5-flash-image",
      contents: "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme",
    });

    for (const part of response.candidates[0].content.parts) {
      if (part.text) {
        console.log(part.text);
      } else if (part.inlineData) {
        const buffer = Buffer.from(part.inlineData.data, "base64");
        fs.writeFileSync("generated_image.png", buffer);
      }
    }
    ```
  </Tab>
</Tabs>

## Image to Image (with Reference)

Upload a reference image and generate a new one with text prompts:

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    IMG_BASE64=$(base64 -w0 /path/to/cat_image.jpeg)

    curl -s -X POST \
     "https://api.pipellm.ai/v1beta/models/gemini-3-pro-image-preview:streamGenerateContent" \
     -H "x-goog-api-key: $PIPELLM_API_KEY" \
      -H "Content-Type: application/json" \
      -d @- << EOF
    {
      "contents": [{
        "role": "user",
        "parts": [
          {"inlineData": {"mimeType": "image/jpeg", "data": "$IMG_BASE64"}},
    {"text": "Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation"}
    ]
    }],
    "generationConfig": {
    "imageConfig": {
    "aspectRatio": "16:9"
    }
    }
    }
    EOF

    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from google import genai
    from PIL import Image

    client = genai.Client(
      api_key=os.getenv('PIPELLM_API_KEY'),
      http_options={'base_url': 'https://api.pipellm.ai'}
    )

    image = Image.open('/path/to/cat_image.png')

    response = client.models.generate_content(
      model="gemini-2.5-flash-image",
      contents=[
        "Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation",
        image
      ],
    )

    for part in response.parts:
      if part.text is not None:
        print(part.text)
      elif part.inline_data is not None:
        image = part.as_image()
        image.save("edited_image.png")
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";

    const ai = new GoogleGenAI({
    apiKey: process.env.PIPELLM_API_KEY,
    httpOptions: { baseUrl: 'https://api.pipellm.ai' }
    });

    const imageData = fs.readFileSync("cat_image.png");
    const base64Image = imageData.toString("base64");

    const response = await ai.models.generateContent({
    model: "gemini-2.5-flash-image",
    contents: [
    { text: "Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation" },
    { inlineData: { mimeType: "image/png", data: base64Image } }
    ],
    });

    for (const part of response.candidates[0].content.parts) {
    if (part.text) {
    console.log(part.text);
    } else if (part.inlineData) {
    const buffer = Buffer.from(part.inlineData.data, "base64");
    fs.writeFileSync("edited_image.png", buffer);
    }
    }

    ```
  </Tab>
</Tabs>

## Response Format

Image generation responses are multimodal, containing text and base64-encoded image data:

```json theme={null}
{
  "candidates": [{
    "content": {
      "parts": [
        { "text": "Here is your generated image..." },
        {
          "inlineData": {
            "mimeType": "image/png",
            "data": "<BASE64_IMAGE_DATA>"
          }
        }
      ]
    }
  }]
}
```

## More Features

<Card title="Nano Banana Documentation" icon="book" href="https://ai.google.dev/gemini-api/docs/image-generation">
  Supports multi-turn editing, 4K resolution, multi-image composition, and more
</Card>
