# API

## Access

API access is included with the **Ultimate** plan. Create a key in [Settings → API Keys](https://ainanobananapro.com/settings/apikeys) and send it as a bearer token. Keys stop working if the plan no longer includes API access. Keep keys secret — anyone with a key spends your credits.

```
Authorization: Bearer sk-...
```

Jobs cost the same credits as in the studio, use the same resolution and Beast mode limits as your plan, and are refunded automatically if a model fails. Beast mode (several `models` in one request) is a batch feature of Ultimate and Business (up to 8) and Crew (up to 4); on other plans and packs such a request returns `403` with `pro_required` and nothing is charged.

## Start a job

`POST /api/v1/images`

| Field               | Type                  | Notes                                                                                                         |
| ------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------- |
| `model` or `models` | string / string[]     | e.g. `nano-banana-2-1`; several models = Beast mode (Ultimate and team plans only); `auto` picks the best fit |
| `prompt`            | string                | required, up to 3,000 characters                                                                              |
| `references`        | string[]              | up to 8 public `https://` image URLs                                                                          |
| `resolution`        | `1K` \| `2K` \| `4K`  | snapped to what each model supports                                                                           |
| `aspectRatio`       | string                | e.g. `1:1`, `16:9`, `9:16`                                                                                    |
| `relax`             | boolean               | Relax mode on Nano Banana / 2 / Pro — no credits, slower, hourly limit                                        |
| `visibility`        | `public` \| `private` | Private Mode is on by default for your plan                                                                   |

```bash
curl https://ainanobananapro.com/api/v1/images \
  -H "Authorization: Bearer $NBA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"models":["nano-banana-2-1","gpt-image-2-5-flare"],"prompt":"A ceramic mug on a sunlit desk","resolution":"2K"}'
```

The response (`201`) is `{ "data": [ { "id", "model", "status", "credits", ... } ] }` — one job per model.

## Poll a job

`GET /api/v1/images/{id}` returns `{ "data": { "status", "outputs": [url], "error" } }`. `status` is `pending`, `processing`, `success` or `failed`. Poll every few seconds; most images finish in 10–60 seconds.

## Models

`nano-banana`, `nano-banana-2`, `nano-banana-2-1`, `nano-banana-pro`, `gpt-image-2`, `gpt-image-2-5-flare`, `gpt-image-2-5-sunburst`, `seedream-4-5`, `seedream-5-lite`, `seedream-5-pro`, or `auto`.

## Errors

Errors return `{ "error": { "message" } }` with `401` (bad key), `403` (plan has no API access), `402` (not enough credits), `400` (invalid request or plan limit) or `429` (too many requests).

## MCP server for AI agents (Claude, ChatGPT, Cursor)

AINanoBananaPro.com is also a remote [Model Context Protocol](https://modelcontextprotocol.io) server, so AI assistants can generate images with your account. It works on every plan (no API key needed): you sign in once and approve access, and images use your normal credits and plan limits.

**Server URL:** `https://ainanobananapro.com/mcp`

- **Claude:** Settings → Connectors → Add custom connector, then paste the URL.
- **ChatGPT:** Settings → Apps → Developer mode → Create app, then paste the URL.
- **Claude Code:** `claude mcp add --transport http ai-nano-banana-pro https://ainanobananapro.com/mcp`
- **Cursor / VS Code / others:** add a remote (Streamable HTTP) server with the URL above.

| Tool                    | What it does                                                                     |
| ----------------------- | -------------------------------------------------------------------------------- |
| `generate_image`        | Create or edit an image from a prompt and up to 8 reference images; returns URLs |
| `get_generation`        | Status and URLs of a generation that was still running                           |
| `list_image_models`     | Models, credits per resolution, aspect ratios and what your plan includes        |
| `list_my_images`        | Your recent images                                                               |
| `get_credit_balance`    | Credits left and plan limits                                                     |
| `browse_banana_prompts` | Public Banana Prompts gallery with the exact prompts behind each image           |

Protocol: Streamable HTTP with JSON responses. It supports MCP `2026-07-28` (stateless, `server/discover`) and the `initialize` handshake for `2025-11-25` and earlier. It also ships an MCP Apps result card for hosts that show one.

Step-by-step setup for each app: [MCP server guide](https://ainanobananapro.com/mcp-server).

Auth: OAuth 2.1 with S256 PKCE. The user approves each app on a consent screen that shows its name and where it returns. Clients identify themselves with a Client ID Metadata Document (an `https` `client_id`), or register dynamically. The authorization server requires the `resource` to be this site's `/mcp` (RFC 8707), returns `iss` on every redirect (RFC 9207), rotates refresh tokens and supports revocation at `/api/auth/mcp/revoke` (RFC 7009). Clients discover all of it from the `401` challenge:

- [`/.well-known/oauth-protected-resource`](https://ainanobananapro.com/.well-known/oauth-protected-resource) (RFC 9728)
- [`/.well-known/oauth-authorization-server`](https://ainanobananapro.com/.well-known/oauth-authorization-server) (RFC 8414)
- [`/mcp/server-card`](https://ainanobananapro.com/mcp/server-card) (MCP Server Card)
- [`/.well-known/ai-catalog.json`](https://ainanobananapro.com/.well-known/ai-catalog.json) and `/.well-known/api-catalog` (RFC 9727)

To disconnect an assistant, use [Settings → Connected apps](https://ainanobananapro.com/settings/connected-apps). Its access stops immediately.

---

Source: https://ainanobananapro.com/api-docs · Site index for AI agents: https://ainanobananapro.com/llms.txt · Full content: https://ainanobananapro.com/llms-full.txt
