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

# Gemini 3 Pro Image

> Google's Gemini 3 Pro Image for AI image generation and editing via Gemini API.

Gemini 3 Pro Image is Google's image generation model, available through Anyfast via the native Gemini API. It can generate images from text prompts and edit existing images using a reference photo.

<Info>
  Google released `gemini-3-pro-image` on May 28, 2026 as the GA version of the native Gemini 3 Pro Image model, also known as Nano Banana Pro. Use this stable model ID instead of `gemini-3-pro-image-preview`, which is deprecated and scheduled to shut down on June 25, 2026.
</Info>

## Key capabilities

* **Text-to-image** — Generate images from text descriptions
* **Image editing** — Pass a reference image in `inline_data` alongside your text instruction
* **Aspect ratio control** — `1:1`, `4:3`, `3:4`, `16:9`, `9:16`
* **Resolution control** — `1K` (\~1024px), `2K` (\~2048px), `4K` (\~4096px) on the long edge
* **Multi-modal output** — Return both the image and a text caption with `responseModalities: ["TEXT", "IMAGE"]`

> **Note:** If you need the generated image returned as a URL, select the **Aggregate-NanoUrl** group when creating your API token.

## Text-to-image example

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://www.anyfast.ai/v1beta/models/gemini-3-pro-image:generateContent?key=YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "contents": [
        {
          "role": "user",
          "parts": [
            { "text": "Generate an image of a sunset over mountains" }
          ]
        }
      ],
      "generationConfig": {
        "responseModalities": ["TEXT", "IMAGE"],
        "imageConfig": {
          "aspectRatio": "16:9",
          "imageSize": "1K"
        }
      }
    }'
  ```

  ```python Python theme={null}
  import requests, base64

  url = "https://www.anyfast.ai/v1beta/models/gemini-3-pro-image:generateContent"
  response = requests.post(url, params={"key": "YOUR_API_KEY"}, json={
      "contents": [
          {
              "role": "user",
              "parts": [{"text": "Generate an image of a sunset over mountains"}]
          }
      ],
      "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"],
          "imageConfig": {"aspectRatio": "16:9", "imageSize": "1K"}
      }
  })

  for part in response.json()["candidates"][0]["content"]["parts"]:
      if "inline_data" in part:
          with open("output.jpg", "wb") as f:
              f.write(base64.b64decode(part["inline_data"]["data"]))
          print("Image saved to output.jpg")
      elif "text" in part:
          print("Caption:", part["text"])
  ```
</CodeGroup>

## Image editing example (with reference image)

Include both a `text` instruction and an `inline_data` reference image in the same `parts` array.

<CodeGroup>
  ```bash cURL theme={null}
  # First encode your image to base64:
  # BASE64=$(base64 -i your_photo.jpg)
  #
  # Then send the request:
  curl "https://www.anyfast.ai/v1beta/models/gemini-3-pro-image:generateContent?key=YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "contents": [
        {
          "role": "user",
          "parts": [
            {
              "text": "Hi, this is a picture of me. Can you add a llama next to me?"
            },
            {
              "inline_data": {
                "mime_type": "image/jpeg",
                "data": "<YOUR_BASE64_ENCODED_IMAGE>"
              }
            }
          ]
        }
      ],
      "generationConfig": {
        "responseModalities": ["TEXT", "IMAGE"],
        "imageConfig": {
          "aspectRatio": "1:1",
          "imageSize": "1K"
        }
      }
    }'
  ```

  ```python Python theme={null}
  import requests, base64

  # Read and encode your reference image
  with open("your_photo.jpg", "rb") as f:
      image_b64 = base64.b64encode(f.read()).decode("utf-8")

  url = "https://www.anyfast.ai/v1beta/models/gemini-3-pro-image:generateContent"
  response = requests.post(url, params={"key": "YOUR_API_KEY"}, json={
      "contents": [
          {
              "role": "user",
              "parts": [
                  {
                      "text": "Hi, this is a picture of me. Can you add a llama next to me?"
                  },
                  {
                      "inline_data": {
                          "mime_type": "image/jpeg",
                          "data": image_b64          # ← paste your base64 string here
                      }
                  }
              ]
          }
      ],
      "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"],
          "imageConfig": {"aspectRatio": "1:1", "imageSize": "1K"}
      }
  })

  for part in response.json()["candidates"][0]["content"]["parts"]:
      if "inline_data" in part:
          with open("output.jpg", "wb") as f:
              f.write(base64.b64decode(part["inline_data"]["data"]))
          print("Image saved to output.jpg")
      elif "text" in part:
          print("Caption:", part["text"])
  ```
</CodeGroup>

## Parameters

| Parameter                                  | Type   | Required | Description                                                   |
| ------------------------------------------ | ------ | -------- | ------------------------------------------------------------- |
| `key`                                      | string | Yes      | API key (query parameter)                                     |
| `contents[].parts[].text`                  | string | Yes      | Text prompt or instruction                                    |
| `contents[].parts[].inline_data.mime_type` | string | No       | Reference image type: `image/jpeg`, `image/png`, `image/webp` |
| `contents[].parts[].inline_data.data`      | string | No       | Base64-encoded reference image                                |
| `generationConfig.responseModalities`      | array  | Yes      | `["IMAGE"]` or `["TEXT", "IMAGE"]`                            |
| `generationConfig.imageConfig.aspectRatio` | string | No       | `1:1` / `4:3` / `3:4` / `16:9` / `9:16`                       |
| `generationConfig.imageConfig.imageSize`   | string | No       | `1K` / `2K` / `4K` (default: `1K`)                            |

<Card title="API Reference" icon="code" href="/api-reference/model-api/google/gemini-3-pro-image">
  View the interactive API playground for Gemini 3 Pro Image.
</Card>

<script src="/feedback.js" />
