> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nanobananaapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Image (Nanobanana 2)

> Submit NanoBanana Generate-2 image generation task using the latest NanoBanana model.

### Important Notes

* Task ID returned in the response is used to query task status via the **Get Task Details** endpoint
* If `callBackUrl` is provided, task completion notifications will be sent to that URL via POST request
* The `prompt` field supports up to 20,000 characters; more detailed prompts generally produce better results
* When `imageUrls` is an empty array, the request runs in pure text-to-image mode; when URLs are provided, it runs in image-to-image / reference mode
* You can control the aspect ratio, resolution, and output format using `aspectRatio`, `resolution`, and `outputFormat`

### Parameter Overview

* **prompt**: Text prompt (required), up to 20,000 characters
* **imageUrls**: Array of reference image URLs; use an empty array for text-to-image mode, up to 14 images
* **aspectRatio**: Aspect ratio of the generated image. Supported: 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9, auto
* **resolution**: Output quality level, one of 1K / 2K / 4K
* **googleSearch**: Whether to enable Google Web Search grounding (default: false)
* **outputFormat**: Output format, either png or jpg (default: jpg)
* **callBackUrl**: Optional callback URL to receive async task completion notifications


## OpenAPI

````yaml nanobanana-api/nanobanana-api.json post /api/v1/nanobanana/generate-2
openapi: 3.0.0
info:
  title: NanoBanana API
  description: NanoBanana API Documentation - Image Generation and Editing API
  version: 1.0.0
  contact:
    name: Technical Support
    email: support@nanobananaapi.ai
servers:
  - url: https://api.nanobananaapi.ai
    description: API Server
security:
  - BearerAuth: []
paths:
  /api/v1/nanobanana/generate-2:
    post:
      summary: Generate Image (Nanobanana 2)
      operationId: generate-image-2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
              properties:
                prompt:
                  type: string
                  description: >-
                    Text prompt for image generation (required). Controls the
                    content and style of the generated image. Maximum length:
                    20,000 characters.
                  maxLength: 20000
                  example:
                    - a happy dog running in the park
                imageUrls:
                  type: array
                  description: >-
                    Image URLs for image-to-image mode. Use an empty array for
                    pure text-to-image generation. Supports up to 14 reference
                    images.
                  items:
                    type: string
                    format: uri
                  default: []
                  maxItems: 14
                aspectRatio:
                  type: string
                  description: Aspect ratio of the generated image.
                  enum:
                    - '1:1'
                    - '1:4'
                    - '1:8'
                    - '2:3'
                    - '3:2'
                    - '3:4'
                    - '4:1'
                    - '4:3'
                    - '4:5'
                    - '5:4'
                    - '8:1'
                    - '9:16'
                    - '16:9'
                    - '21:9'
                    - auto
                  default: auto
                resolution:
                  type: string
                  description: >-
                    Output resolution quality. Higher values produce larger and
                    sharper images at higher cost.
                  enum:
                    - 1K
                    - 2K
                    - 4K
                  default: 1K
                googleSearch:
                  type: boolean
                  description: >-
                    Use Google Web Search grounding to generate images based on
                    real-time information.
                  default: false
                outputFormat:
                  type: string
                  description: Output image format.
                  enum:
                    - png
                    - jpg
                  default: jpg
                callBackUrl:
                  type: string
                  format: uri
                  description: >-
                    Optional callback URL for async notifications when the task
                    is completed.
              example:
                prompt: a happy dog running in the park
                imageUrls: []
                aspectRatio: auto
                resolution: 1K
                googleSearch: false
                outputFormat: jpg
                callBackUrl: https://example-callback.com
      responses:
        '200':
          description: Request successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    description: Response status code
                    example: 200
                  message:
                    type: string
                    description: Response message
                    example: success
                  data:
                    type: object
                    properties:
                      taskId:
                        type: string
                        description: Task ID for querying task status
                        example: task_12345678
              example:
                code: 200
                message: success
                data:
                  taskId: task_12345678
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        All APIs require authentication via Bearer Token.


        Get API Key:

        1. Visit [API Key Management Page](https://nanobananaapi.ai/api-key) to
        get your API Key


        Usage:

        Add to request header:

        Authorization: Bearer YOUR_API_KEY


        Note:

        - Keep your API Key secure and do not share it with others

        - If you suspect your API Key has been compromised, reset it immediately
        in the management page

````