# Nano Banana 2

> Gemini 3.1 Flash Image: fast generation and editing, accurate text in images, up to 14 references.

Nano Banana 2 (Gemini 3.1 Flash Image) is Google's main image model. It keeps characters consistent, renders legible text inside images, understands long prompts (up to 20,000 characters) and accepts up to 14 reference images for editing, compositing and style transfer.

| Mode | ID | Price |
|---|---|---|
| [Image to Image](#image-to-image) | `nano-banana-2` | $0.02 |
| [Text to Image](#text-to-image) | `nano-banana-2` | $0.02 |

Both modes are one model, `nano-banana-2`: pass photos and it edits them or uses them as references.

## Image to Image

Upload a photo and describe what to change. ID: `nano-banana-2` · $0.02 per image · ~1.5 min

**Parameters** (field `input`)

| Parameter | Required | Description | Values (default in bold) |
|---|---|---|---|
| `prompt` | yes | What to draw or what to change | text, up to 20000 chars |
| `image_input` | yes | Links to your photos (https), up to 14 | `["https://…"]` |
| `aspect_ratio` | no | Image shape | **`auto`** `1:1` `2:3` `3:2` `1:4` `4:1` `3:4` `4:3` `4:5` `5:4` `1:8` `8:1` `9:16` `16:9` `21:9` |
| `resolution` | no | Quality: 1K is faster, 2K has more detail | **`1K`** `2K` `4K` |
| `output_format` | no | File format | **`jpg`** `png` |

**Example**

```bash
curl -X POST https://ai.aimixmedia.site/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"nano-banana-2","input":{"prompt":"Make the background a neon city at night","image_input":["https://ai.aimixmedia.site/static/img/previews/gpt-t2i.jpg"],"aspect_ratio":"auto","resolution":"1K"}}'
```

```python
import os, requests

r = requests.post(
    "https://ai.aimixmedia.site/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "nano-banana-2",
      "input": {
        "prompt": "Make the background a neon city at night",
        "image_input": [
          "https://ai.aimixmedia.site/static/img/previews/gpt-t2i.jpg"
        ],
        "aspect_ratio": "auto",
        "resolution": "1K"
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
```

```javascript
const r = await fetch("https://ai.aimixmedia.site/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "nano-banana-2",
    "input": {
      "prompt": "Make the background a neon city at night",
      "image_input": [
        "https://ai.aimixmedia.site/static/img/previews/gpt-t2i.jpg"
      ],
      "aspect_ratio": "auto",
      "resolution": "1K"
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }
```

## Text to Image

Describe the picture and the model creates it from scratch. ID: `nano-banana-2` · $0.02 per image · ~1.5 min

**Parameters** (field `input`)

| Parameter | Required | Description | Values (default in bold) |
|---|---|---|---|
| `prompt` | yes | What to draw or what to change | text, up to 20000 chars |
| `aspect_ratio` | no | Image shape | **`auto`** `1:1` `2:3` `3:2` `1:4` `4:1` `3:4` `4:3` `4:5` `5:4` `1:8` `8:1` `9:16` `16:9` `21:9` |
| `resolution` | no | Quality: 1K is faster, 2K has more detail | **`1K`** `2K` `4K` |
| `output_format` | no | File format | **`jpg`** `png` |

**Example**

```bash
curl -X POST https://ai.aimixmedia.site/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"nano-banana-2","input":{"prompt":"A cat astronaut in a neon city, cinematic light","aspect_ratio":"auto","resolution":"1K"}}'
```

```python
import os, requests

r = requests.post(
    "https://ai.aimixmedia.site/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "nano-banana-2",
      "input": {
        "prompt": "A cat astronaut in a neon city, cinematic light",
        "aspect_ratio": "auto",
        "resolution": "1K"
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
```

```javascript
const r = await fetch("https://ai.aimixmedia.site/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "nano-banana-2",
    "input": {
      "prompt": "A cat astronaut in a neon city, cinematic light",
      "aspect_ratio": "auto",
      "resolution": "1K"
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }
```

## Result

Same as any task: call [recordInfo](https://docs.aimixmedia.site/en/endpoints/record-info) or receive a [callback](https://docs.aimixmedia.site/en/callbacks). Image links are in `resultJson` (kept for 30 days).

Upload your photos via [files/upload](https://docs.aimixmedia.site/en/endpoints/upload) or pass any public https links.
