Back to docs

Text-to-Image API

Create an asynchronous image generation task from a text prompt. This same endpoint supports nano, nano2, and nano2pro through the model field.

Nano AI API Base URL: https://nanobnana.com

Authentication

Send your API key as a Bearer token. You can create keys from Dashboard > API Keys.

http
Authorization: Bearer YOUR_API_KEY

Model Selection

Use this same /api/generate endpoint for every text-to-image model. model is optional only for backward compatibility; new integrations should set it explicitly.

nano

Original Nano AI Fast backend. Default when model is omitted.

nano2

Nano AI 2 backend for new integrations.

nano2pro

Nano AI 2 Pro backend for higher quality output.

Endpoint

The endpoint returns a task_id immediately. Poll /api/status to retrieve the final result.

Request bodyJSON
prompt:string

Text prompt describing the image to generate.

model:optional string

Supported values: nano, nano2, nano2pro. Defaults to nano.

aspect_ratio:optional string

Output aspect ratio for Nano AI 2 models, such as 1:1, 16:9, or 9:16. Defaults to 1:1.

size / resolution:optional string

Resolution. The API accepts either field and normalizes it for the selected backend. Supported values: 1K, 2K, 4K.

format / output_format:optional string

Output image format. Defaults to png.

Example request

json
{
  "prompt": "A professional product photo of a modern wristwatch on a clean white background",
  "model": "nano2",
  "aspect_ratio": "1:1",
  "size": "1K",
  "format": "png"
}

Example response

The task has been accepted for asynchronous processing.

{
  "code": 200,
  "message": "success",
  "task_id": "nprob71e549f645122eb8db5f75af2c11nono",
  "model": "nano2",
  "data": {
    "task_id": "nprob71e549f645122eb8db5f75af2c11nono"
  }
}

Next Step

Save the returned task_id and poll the status endpoint until the task reaches a final state.

View Query Status API

Common Errors

{
  "code": 400,
  "message": "Bad Request: 'prompt' is required.",
  "data": null
}