Nano Banana 2 Lite Serverless API
Generate and edit 1K images in about four seconds.
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) 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
https://api.segmind.com/v1/nano-banana-2-liteParameters
promptrequiredstringText description of the image to generate; required. Be specific about subject, lighting, camera.
"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_ratiooptionalstringOutput shape from 15 presets; default 1:1. Use 16:9 cinematic, 9:16 mobile, auto adaptive.
"1:1""auto""1:1""2:3""3:2""4:3""3:4""4:5""5:4""16:9""9:16"+5 moreimage_urlsoptionalstring[]Optional reference image URLs for editing or multi-image composition. Add up to 14.
output_formatoptionalstringFile type, jpg or png; default jpg. Choose png for sharper edges and text.
"jpg""jpg""png"output_resolutionoptionalstringImage resolution; only 1K is supported. Leave at 1K for every generation.
"1K""1K"response_modalitiesoptionalstringReturn IMAGE only or TEXT_AND_IMAGE; default TEXT_AND_IMAGE. Use IMAGE to skip text output.
"TEXT_AND_IMAGE""TEXT_AND_IMAGE""IMAGE"safety_toleranceoptionalintegerContent moderation strictness from 1 to 6; default 4. Lower is stricter, higher permissive.
4123456seedoptionalintegerRandom integer seeding generation for reproducibility. Reuse a value to reproduce an image.
778812thinking_leveloptionalstringReasoning depth, minimal or high; default high. Use high for complex prompts, minimal faster.
"high""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
POST /v2/nano-banana-2-liteSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- 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.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out