Nano Banana 2 Lite Serverless API

Generate and edit 1K images in about four seconds.

~12.88s
POST /v2/nano-banana-2-lite · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5# Async (v2): submit to the queue and block until COMPLETED.
 6# run() returns the final result dict (600s deadline, 1.0s poll by default).
 7result = segmind.run(
 8    "nano-banana-2-lite",
 9    prompt="A photorealistic close-up product photograph of a rustic artisan coffee bag standing on a warm wooden cafe counter. The kraft-paper packaging has a beautifully printed label reading 'NANO ROAST' in bold vintage serif lettering, with 'Single Origin - Medium Roast' in smaller elegant script beneath it. Soft morning window light, gentle bokeh of a cozy cafe interior in the background, roasted coffee beans scattered on the counter, shallow depth of field, crisp focus on the label, high-end commercial product photography, 8k.",
10    seed=778812,
11    aspect_ratio="1:1",
12    output_format="jpg",
13    thinking_level="high",
14    safety_tolerance=4,
15    output_resolution="1K",
16    response_modalities="TEXT_AND_IMAGE",
17)
18print(result["status"])                      # COMPLETED
19print(result.get("output"))                  # model output (e.g. media URL)
20print(result["metrics"]["inference_time"])   # server compute seconds
21
22# --- Or submit + poll manually (track request_id, control the cadence) ---
23from segmind import SegmindClient, InferenceFailed, InferenceTimeout
24
25client = SegmindClient()                      # reads SEGMIND_API_KEY
26payload = {
27    "prompt": "A photorealistic close-up product photograph of a rustic artisan coffee bag standing on a warm wooden cafe counter. The kraft-paper packaging has a beautifully printed label reading 'NANO ROAST' in bold vintage serif lettering, with 'Single Origin - Medium Roast' in smaller elegant script beneath it. Soft morning window light, gentle bokeh of a cozy cafe interior in the background, roasted coffee beans scattered on the counter, shallow depth of field, crisp focus on the label, high-end commercial product photography, 8k.",
28    "seed": 778812,
29    "aspect_ratio": "1:1",
30    "output_format": "jpg",
31    "thinking_level": "high",
32    "safety_tolerance": 4,
33    "output_resolution": "1K",
34    "response_modalities": "TEXT_AND_IMAGE",
35}
36job = client.submit_async("nano-banana-2-lite", **payload)
37print(job.request_id)                         # available immediately
38try:
39    result = job.wait(timeout=600, interval=1.0)
40except InferenceTimeout as e:
41    print("still running:", e.request_id)
42except InferenceFailed as e:
43    print("failed:", e.detail)

API Endpoint

POSThttps://api.segmind.com/v1/nano-banana-2-lite

Parameters

promptrequired
string

Text description of the image to generate; required. Be specific about subject, lighting, camera.

Default: "A photorealistic close-up product photograph of a rustic artisan coffee bag standing on a warm wooden cafe counter. The kraft-paper packaging has a beautifully printed label reading 'NANO ROAST' in bold vintage serif lettering, with 'Single Origin - Medium Roast' in smaller elegant script beneath it. Soft morning window light, gentle bokeh of a cozy cafe interior in the background, roasted coffee beans scattered on the counter, shallow depth of field, crisp focus on the label, high-end commercial product photography, 8k."
aspect_ratiooptional
string

Output shape from 15 presets; default 1:1. Use 16:9 cinematic, 9:16 mobile, auto adaptive.

Default: "1:1"
Allowed values (15 total):
"auto""1:1""2:3""3:2""4:3""3:4""4:5""5:4""16:9""9:16"+5 more
image_urlsoptional
string[]

Optional reference image URLs for editing or multi-image composition. Add up to 14.

output_formatoptional
string

File type, jpg or png; default jpg. Choose png for sharper edges and text.

Default: "jpg"
Allowed values :
"jpg""png"
output_resolutionoptional
string

Image resolution; only 1K is supported. Leave at 1K for every generation.

Default: "1K"
Allowed values :
"1K"
response_modalitiesoptional
string

Return IMAGE only or TEXT_AND_IMAGE; default TEXT_AND_IMAGE. Use IMAGE to skip text output.

Default: "TEXT_AND_IMAGE"
Allowed values :
"TEXT_AND_IMAGE""IMAGE"
safety_toleranceoptional
integer

Content moderation strictness from 1 to 6; default 4. Lower is stricter, higher permissive.

Default: 4
Allowed values :
123456
seedoptional
integer

Random integer seeding generation for reproducibility. Reuse a value to reproduce an image.

Default: 778812
thinking_leveloptional
string

Reasoning depth, minimal or high; default high. Use high for complex prompts, minimal faster.

Default: "high"
Allowed values :
"minimal""high"

Response Type

Returns: Image

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/nano-banana-2-lite

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out