# Nano Banana 2

> Google's next-gen image model powered by Gemini 3.1 Flash with native 2K/4K resolution, chain-of-thought reasoning, precise multi-language text rendering, and up to 14 reference images.

## Overview

- Submit: `https://api.poyo.ai/api/generate/submit`
- Status: `https://api.poyo.ai/api/generate/status/{task_id}`
- Page: https://poyo.ai/models/nano-banana-2
- Model page ID: `nano-banana-2`
- API model IDs: `nano-banana-2-new`, `nano-banana-2-new-edit`, `nano-banana-2-official`, `nano-banana-2-official-edit`
- Category: Image
- Auth: `Authorization: Bearer $POYO_API_KEY`
- Create a key at https://poyo.ai/dashboard/api-key

This model uses PoYo's unified async API. POST the JSON body below, then poll status with the returned `task_id` or receive a webhook on `callback_url`. Failed tasks are not charged.

## Pricing

- nano-banana-2-new@1K: 5 credits ($0.025) per generation
- nano-banana-2-new@2K: 8 credits ($0.040) per generation
- nano-banana-2-new@4K: 12 credits ($0.060) per generation
- nano-banana-2-official@0.5K: 7 credits ($0.035) per generation
- nano-banana-2-official@1K: 10 credits ($0.050) per generation
- nano-banana-2-official@2K: 15 credits ($0.075) per generation
- nano-banana-2-official@4K: 20 credits ($0.100) per generation

For more details, see https://poyo.ai/models/nano-banana-2.

## API Information

The request envelope is always `{ model, input, callback_url? }`. Input fields below are nested under `input`.

### Request envelope

- `model` (`ModelEnum`, required):
  Nano Banana 2 model identifier
  - Options: `"nano-banana-2-new"`, `"nano-banana-2-new-edit"`, `"nano-banana-2-official"`, `"nano-banana-2-official-edit"`
- `callback_url` (`string`, optional):
  Webhook callback URL for result notifications
  - Examples: "https://your-domain.com/callback"

### Input Schema

Input parameters for generation. Supported fields vary by model family.

The API accepts the following `input` parameters:

- `prompt` (`string`, required):
  Generation prompt describing the desired output
  - Length: 0 to 20000 characters
  - Examples: "A beautiful sunset over the ocean"
- `image_urls` (`list`, optional):
  Reference image URLs. Required for edit models and supports up to 14 images.
  - Array of string
  - Examples: `[]`
- `size` (`SizeEnum`, optional):
  Image size ratio. `nano-banana-2-new` supports standard aspect ratios. `nano-banana-2-official` also supports `auto`, `4:1`, `1:4`, `8:1`, and `1:8`.
  - Options: `"auto"`, `"1:1"`, `"2:3"`, `"3:2"`, `"3:4"`, `"4:3"`, `"4:5"`, `"5:4"`, `"9:16"`, `"16:9"`, `"21:9"`, `"4:1"`, `"1:4"`, `"8:1"`, `"1:8"`
  - Examples: "16:9"
- `resolution` (`ResolutionEnum`, optional):
  Output image resolution. `nano-banana-2-new` supports `1K`, `2K`, `4K`. `nano-banana-2-official` also supports `0.5K`.
  - Default: `"1K"`
  - Options: `"0.5K"`, `"1K"`, `"2K"`, `"4K"`
  - Examples: "1K"
- `output_format` (`OutputFormatEnum`, optional):
  Nano Banana 2 Official only. Output image format.
  - Default: `"png"`
  - Options: `"png"`, `"jpg"`, `"jpeg"`, `"webp"`
  - Examples: "png"
- `google_search` (`boolean`, optional):
  Use Google Web Search grounding to generate images based on real-time information. Supported by both model families; official models map it internally to `enable_web_search`.
  - Default: `false`
  - Examples: `false`
- `seed` (`integer`, optional):
  Nano Banana 2 Official only. Optional random seed for reproducible output.
  - Examples: `24680`

Required Parameters Example:

```json
{
  "model": "nano-banana-2-new",
  "input": {
    "prompt": "A cyberpunk street scene with neon signs and rain",
    "size": "16:9",
    "resolution": "2K"
  }
}
```

Full Example:

```json
{
  "model": "nano-banana-2-new",
  "input": {
    "prompt": "A cyberpunk street scene with neon signs and rain",
    "size": "16:9",
    "resolution": "2K",
    "image_urls": [],
    "output_format": "png",
    "google_search": false,
    "seed": 24680
  }
}
```

Nano Banana 2 Image Edit:

```json
{
  "model": "nano-banana-2-new-edit",
  "input": {
    "prompt": "Add colorful flowers in the foreground",
    "image_urls": [
      "https://example.com/landscape.jpg"
    ],
    "size": "16:9",
    "resolution": "2K"
  }
}
```

Nano Banana 2 Official Image Generation:

```json
{
  "model": "nano-banana-2-official",
  "input": {
    "prompt": "A product hero shot of a transparent glass perfume bottle on reflective stone, soft daylight, premium editorial composition",
    "size": "auto",
    "resolution": "0.5K",
    "output_format": "webp",
    "google_search": true,
    "seed": 24680
  }
}
```

### Output Schema

Submit returns a `task_id`. Poll `GET /api/generate/status/{task_id}` until `status` is `finished` or `failed`. Completed media is in `data.files`.

Response fields:

- `code` (`CodeEnum`, required):
  Business status code. `200` means success; any other value means the request failed. Always check this field: some validation errors return HTTP 200 with `code: 400` in the body.
  
  - `200`: Success
  - `400`: Invalid request parameters
  - `401`: Missing or invalid API key
  - `402`: Insufficient credits
  - `403`: Permission denied
  - `404`: Resource not found
  - `408`: Request timeout
  - `429`: Rate limit exceeded
  - `500`: Internal server error
  - `502`: Upstream service error
  - `503`: Service unavailable
  
  See [Error Codes](/api-manual/error-codes) for details.
  - Options: `200`, `400`, `401`, `402`, `403`, `404`, `408`, `429`, `500`, `502`, `503`
  - Examples: `200`
- `data` (`object`, required):

Example Response:

```json
{
  "code": 200,
  "data": {
    "task_id": "task_example",
    "status": "finished",
    "files": [
      {
        "file_url": "https://storage.poyo.ai/nano-banana-2/examples/bioluminescent-bay.png",
        "file_type": "image"
      }
    ]
  }
}
```

## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://api.poyo.ai/api/generate/submit \
  --header "Authorization: Bearer $POYO_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"model":"nano-banana-2-new","input":{"prompt":"A cyberpunk street scene with neon signs and rain","size":"16:9","resolution":"2K"}}'
```

### Python

```python
import json
import os
import time
import requests

API = "https://api.poyo.ai"
headers = {
    "Authorization": f"Bearer {os.environ['POYO_API_KEY']}",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"model\": \"nano-banana-2-new\",\n  \"input\": {\n    \"prompt\": \"A cyberpunk street scene with neon signs and rain\",\n    \"size\": \"16:9\",\n    \"resolution\": \"2K\"\n  }\n}")

submit = requests.post(f"{API}/api/generate/submit", headers=headers, json=payload)
submit.raise_for_status()
task_id = submit.json()["data"]["task_id"]

while True:
    status = requests.get(f"{API}/api/generate/status/{task_id}", headers=headers)
    status.raise_for_status()
    data = status.json()["data"]
    if data["status"] in ("finished", "failed"):
        print(data)
        break
    time.sleep(2)
```

### JavaScript

```javascript
const headers = {
  Authorization: `Bearer ${process.env.POYO_API_KEY}`,
  "Content-Type": "application/json",
};

const submit = await fetch("https://api.poyo.ai/api/generate/submit", {
  method: "POST",
  headers,
  body: JSON.stringify({
  "model": "nano-banana-2-new",
  "input": {
    "prompt": "A cyberpunk street scene with neon signs and rain",
    "size": "16:9",
    "resolution": "2K"
  }
}),
});

const submitted = await submit.json();
const taskId = submitted.data.task_id;

while (true) {
  const statusResponse = await fetch(`https://api.poyo.ai/api/generate/status/${taskId}`, { headers });
  const status = await statusResponse.json();
  if (["finished", "failed"].includes(status.data.status)) {
    console.log(status.data);
    break;
  }
  await new Promise((resolve) => setTimeout(resolve, 2000));
}
```

## Additional Resources

### Documentation

- [Model Playground](https://poyo.ai/models/nano-banana-2)
- [API Documentation](https://docs.poyo.ai/api-manual/image-series/nano-banana-2-new)
- [API Documentation (Markdown)](https://docs.poyo.ai/api-manual/image-series/nano-banana-2-new.md)
- [Task status](https://docs.poyo.ai/api-manual/task-management/query-task-status)
- [Webhooks](https://docs.poyo.ai/api-manual/task-management/webhooks)

### Other agent-readable surfaces

- [Platform overview](https://poyo.ai/llms.txt)
- [Documentation index](https://docs.poyo.ai/llms.txt)
- [Full documentation text](https://docs.poyo.ai/llms-full.txt)
- Any other model: `https://poyo.ai/models/<model-id>/llms.txt`
