---
title: "Generate or Edit Image"
method: POST
path: "/api/v1/nanobanana/generate"
---

# Generate or Edit Image

`POST /api/v1/nanobanana/generate`

Submit Nanobanana image generation or editing task.

### Usage Modes
1. **Text-to-Image Generation** (TEXTTOIAMGE)
   - Provide `prompt` and set `type` to "TEXTTOIAMGE"
   - Model will generate a new image based on the text description

2. **Image-to-Image Editing** (IMAGETOIAMGE)
   - Provide `prompt`, `imageUrls` and set `type` to "IMAGETOIAMGE"
   - Model will edit the input images according to the prompt

### Important Notes
- You can generate 1-4 images per request
- Callback URL is required for task completion notifications

## Request body

- object
  - `prompt` string, required — Text prompt describing the desired image or edit.
  - `numImages` integer — Number of images to generate. Min: 1, Max: 4
  - `imageUrls` string[] — Array of input image URLs for image editing mode
  - `type` 'IMAGETOIAMGE' | 'TEXTTOIAMGE', required — Generation type: - TEXTTOIAMGE: Text to Image - IMAGETOIAMGE: Image Editing
  - `watermark` string — Watermark text to add to generated images
  - `image_size` '1:1' | '9:16' | '16:9' | '3:4' | '4:3' | '3:2' | '2:3' | '5:4' | '4:5' | '21:9' — Image aspect ratio. Supported ratios: - 1:1: Square - 9:16: Portrait (mobile) - 16:9: Landscape (widescreen) - 3:4: Portrait - 4:3: Landscape (traditional) - 3:2: Landscape (photo) - 2:3: Portrait (photo) - 5:4: Portrait (close to square) - 4:5: Portrait (close to square) - 21:9: Ultra-wide landscape
  - `callBackUrl` string, uri, required — Callback URL to receive task completion notifications (required)

## Response `200`

Request successful

- object
  - `code` 200 | 400 | 401 | 500 — Response status code - **200**: Success - **400**: Parameter error - **401**: Unauthorized - **500**: Server internal error
  - `msg` string — Response message
  - `data` object
    - `taskId` string — Task ID for tracking the generation progress

## Other responses

- `400` — Parameter error
- `401` — Unauthorized
- `500` — Server internal error

---

[API](https://skmtc.dev/nanobananaapi/apis/common-api.md) · [All operations](https://skmtc.dev/nanobananaapi/apis/common-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/nanobananaapi/common-api/revisions/83dd71119edc/schema)
