# NanoBanana API (`imageaibot/nanobanana-api`) Actor

NanoBanana Image API lets you submit AI image generation tasks and query task status with simple, production-ready inputs. It supports prompt-based generation, optional image references, aspect ratio and size controls (1K/2K/4K), plus webhook callback.website: [NanoBanana](https://zh-nanobanana.com)

- **URL**: https://apify.com/imageaibot/nanobanana-api.md
- **Developed by:** [ImageAI Bot](https://apify.com/imageaibot) (community)
- **Categories:** AI, E-commerce, Automation
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $40.00 / 1,000 1ks

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## NanoBanana Image API

Create high-quality AI images on Apify with a simple, low-cost workflow.

This Actor is designed for users who want:

1. Cheap, predictable pricing by image size
2. A fast and simple way to submit image generation tasks
3. Support for `1K`, `2K`, and `4K` output tiers
4. A clean query flow to check task status and get the final image URL

### Other image API

1. [Image 2 API](https://apify.com/imageaibot/image-2-api)
2. [NanoBanana API](https://apify.com/imageaibot/nanobanana-api)
3. [Midjourney API](https://apify.com/imageaibot/midjourney-bot)

### Why use this Actor

1. Low cost for testing and production usage
2. Easy to use directly from Apify Console or API
3. Flexible input for both single-prompt and reference-image workflows
4. Built-in size selection for different quality and price needs

### Input

#### Generate task

Use `operation=generate` when you want to create an image task.

Required:

1. `prompt`

Optional:

1. `imgUrls` - reference images, up to 5
2. `aspectRatio` - `auto`, `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`
3. `size` - `1K`, `2K`, or `4K`
4. `notifyHook` - webhook callback URL

#### Query task

Use `operation=query` when you want to check task status.

Required:

1. `taskId`

### Pricing

Pricing is based on the selected size:

1. `1K` - best for quick tests and lower cost
2. `2K` - balanced quality and cost
3. `4K` - highest quality tier

You can set your own prices for each tier through environment variables.

### Quick Demo

The default input already includes sample text and two sample reference images, so you can test it immediately.

#### Demo 1: Generate an image task

```json
{
    "operation": "generate",
    "prompt": "The woman in picture 1 is wearing the clothes from picture 2",
    "imgUrls": [
        "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20251127/w1024_h1024_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-20ee04d2acc3a16268038b29df750874.jpeg",
        "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20250923/w1156_h1536_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-18debe4a45842af06885be6e3fb54d13.png"
    ],
    "aspectRatio": "auto",
    "size": "2K"
}
```

Example response:

```json
{
    "operation": "generate",
    "taskId": "123"
}
```

#### Demo 2: Query the task result

```json
{
    "operation": "query",
    "taskId": "123"
}
```

Example response:

```json
{
    "operation": "query",
    "taskId": "123",
    "status": "SUCCESS",
    "imgUrl": "https://example.com/image.png"
}
```

### Output

Generate returns the submitted task information, including the task ID.

Query returns:

1. `taskId`
2. `status`
3. `imgUrl`

### Best For

1. Product mockups
2. Fashion and clothing transformation demos
3. Fast image generation tests
4. Affordable tiered image workflows

### Notes

1. This Actor submits generation tasks first, then you can query the result later.
2. If you need higher quality, choose a larger size tier.
3. The console input already includes sample prompt and reference images for easier testing.
4. NanoBanana: [NanoBanana](https://zh-nanobanana.com)

# Actor input Schema

## `operation` (type: `string`):

generate: create image task, query: get task status by taskId

## `prompt` (type: `string`):

Used only when operation=generate

## `imgUrls` (type: `array`):

Optional reference images, up to 5

## `aspectRatio` (type: `string`):

Optional aspect ratio (generate only)

## `size` (type: `string`):

Pricing tier is mapped by size: 1K / 2K / 4K (generate only)

## `notifyHook` (type: `string`):

Optional webhook URL for upstream callback (generate only)

## `taskId` (type: `string`):

Required when operation=query

## Actor input object example

```json
{
  "operation": "generate",
  "prompt": "The woman in picture 1 is wearing the clothes from picture 2",
  "imgUrls": [
    "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20251127/w1024_h1024_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-20ee04d2acc3a16268038b29df750874.jpeg",
    "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20250923/w1156_h1536_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-18debe4a45842af06885be6e3fb54d13.png"
  ],
  "aspectRatio": "auto",
  "size": "1K"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "operation": "generate",
    "prompt": "The woman in picture 1 is wearing the clothes from picture 2",
    "imgUrls": [
        "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20251127/w1024_h1024_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-20ee04d2acc3a16268038b29df750874.jpeg",
        "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20250923/w1156_h1536_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-18debe4a45842af06885be6e3fb54d13.png"
    ],
    "aspectRatio": "auto",
    "size": "1K"
};

// Run the Actor and wait for it to finish
const run = await client.actor("imageaibot/nanobanana-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "operation": "generate",
    "prompt": "The woman in picture 1 is wearing the clothes from picture 2",
    "imgUrls": [
        "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20251127/w1024_h1024_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-20ee04d2acc3a16268038b29df750874.jpeg",
        "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20250923/w1156_h1536_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-18debe4a45842af06885be6e3fb54d13.png",
    ],
    "aspectRatio": "auto",
    "size": "1K",
}

# Run the Actor and wait for it to finish
run = client.actor("imageaibot/nanobanana-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "operation": "generate",
  "prompt": "The woman in picture 1 is wearing the clothes from picture 2",
  "imgUrls": [
    "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20251127/w1024_h1024_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-20ee04d2acc3a16268038b29df750874.jpeg",
    "https://sh2-1256181000.cos.accelerate.myqcloud.com/w_a/u_a/1/addImg/member-20250923/w1156_h1536_gNXNDQmtVWWhqR05YcFdZT3djVmU2Zz09-18debe4a45842af06885be6e3fb54d13.png"
  ],
  "aspectRatio": "auto",
  "size": "1K"
}' |
apify call imageaibot/nanobanana-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,imageaibot/nanobanana-api"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/skwBe7Mc7GVDzSFJB/builds/zevHE7nMjUPbca5aD/openapi.json
