Skip to content
English

Nano Banana 2

POST /v1/tasks

All models are called through the Unified Async API POST /v1/tasks endpoint; only the input fields differ (see input parameters below).

Model summary

Model name Nano-Banana-2
Type Image generation / editing
Endpoint POST /v1/tasks
Pricing See HiAPI Pricing

Nano Banana 2 is the balanced Nano Banana tier, with optional references, wider ratios, and 1K / 2K / 4K output.

Production guidance

Production guidance
  • For production, pass callback.url at the top level of the request body so HiAPI can notify your service when the task reaches a terminal state.
  • GET /v1/tasks/:id is better for local debugging, low-volume jobs, or fallback reconciliation if a callback is missed.
  • Use callback.when=final. Both success and fail are terminal states, so your service should deduplicate by taskId.

Best suited for

Balanced image generation

Everyday image generation balanced across speed, quality, and price.

promptresolution
Optional references

Reference images are optional; use image_input when useful.

image_input
Wide ratio work

Supports wider and narrower ratios for special layouts and placements.

aspect_ratio
Resolution tiers

1K, 2K, and 4K are documented as current tiers.

resolution

Request parameters

model string required

Fixed value Nano-Banana-2.

example Nano-Banana-2
input object required

Business parameters. Supports text-to-image and optional reference images.

prompt string required

Image generation or editing prompt.

image_input string[] optional

Optional reference image URL array. Text-to-image works without references.

default []
aspect_ratio enum optional

Generated image aspect ratio.

default auto enum: auto1:11:41:82:33:23:44:14:34:55:48:19:1616:921:9
resolution enum optional

Output resolution.

default 1K enum: 1K2K4K
output_format enum optional

Output image format.

default png enum: pngjpg
callback object optional

Optional callback configuration. In production, pass callback.url so HiAPI can notify your service when the task reaches a terminal state.

url string required

HTTPS URL that receives terminal task notifications.

example https://your-domain.com/hiapi/callback
when enum optional

Callback trigger timing. Use final for terminal-state notifications.

default final enum: final

Example requests

Basic text-to-image

Generate without a reference image.

Request body
{
  "model": "Nano-Banana-2",
  "input": {
    "prompt": "A glowing tropical rainforest at night",
    "image_input": [],
    "aspect_ratio": "1:1",
    "resolution": "1K",
    "output_format": "png"
  }
}
Reference generation

Use an optional reference image for style or subject guidance.

Request body
{
  "model": "Nano-Banana-2",
  "input": {
    "prompt": "Restyle this reference into a cinematic product poster",
    "image_input": [
      "https://example.com/reference.png"
    ],
    "aspect_ratio": "16:9",
    "resolution": "1K",
    "output_format": "png"
  }
}

Getting the result

  1. The response returns a taskId immediately without waiting for generation to finish.
  2. In production, prefer waiting for callback.url to receive the terminal notification. For local debugging, poll GET /v1/tasks/:id.
  3. When status=success, download the generated image from output[].url.
  4. When status=fail, fix the request based on the returned error instead of retrying the same invalid payload.

Next steps