POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 const axios = require('axios'); const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/nano-banana-2-lite"; const data = { "seed": 778812, "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.", "aspect_ratio": "1:1", "output_format": "jpg", "thinking_level": "high", "safety_tolerance": 4, "output_resolution": "1K", "response_modalities": "TEXT_AND_IMAGE" }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


seedint ( default: 778812 )

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


promptstr *

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


image_urlsstr ( default: 1 )

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


aspect_ratioenum:str ( default: 1:1 )

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

Allowed values:


output_formatenum:str ( default: jpg )

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

Allowed values:


thinking_levelenum:str ( default: high )

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

Allowed values:


safety_toleranceenum:int ( default: 4 )

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

Allowed values:


output_resolutionenum:str ( default: 1K )

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

Allowed values:


response_modalitiesenum:str ( default: TEXT_AND_IMAGE )

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

Allowed values:


system_promptstr ( default: 1 )

Optional. High-level persona/style rules applied to every generation (e.g. 'You are a product photographer; always use soft studio lighting'). Steers output like a system instruction. Leave blank to omit.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Nano Banana 2 Lite — Text-to-Image and Image Editing Model

What is Nano Banana 2 Lite?

Nano Banana 2 Lite is Google's fastest, most cost-efficient image model in the Nano Banana family, technically known as Gemini 3.1 Flash-Lite Image. It is built for rapid ideation and high-velocity developer pipelines, returning a text-to-image result in roughly four seconds. A single drop-in API handles text-to-image generation, image editing, and multi-image composition, and because it is multimodal it can return text alongside images. Despite the speed focus, it keeps reliable prompt adherence, strong character consistency, and legible in-image text rendering, making it Google's recommended upgrade from the legacy Nano Banana (Gemini 2.5 Flash Image).

Key Features

  • Fast text-to-image: outputs in about four seconds for interactive prototyping and high-volume pipelines
  • Image editing and multi-image composition: pass reference images through image_urls to edit or blend up to 14 inputs
  • 1K output across 15 aspect ratios: from 1:1 feeds to 16:9 cinematic and 9:16 mobile
  • Multimodal responses: choose IMAGE only or TEXT_AND_IMAGE
  • Consistent characters across rapid generations for storyboards and try-ons
  • Legible in-image text for labels, captions, and localized ad copy
  • SynthID watermark embedded in every output

Best Use Cases

  • A/B testing ad creatives: spin up localized ad variations and layout concepts in seconds
  • Social and app content at scale: power consumer features where a user is waiting on the result
  • Storyboarding and virtual try-ons: keep character and product identity stable across frames
  • E-commerce mockups: generate product scenes and contextual layouts quickly
  • Image-to-video pipelines: produce a fast base image, then animate it with a video model
  • Rapid prototyping: explore directions cheaply before committing to a heavier model

Prompt Tips and Output Quality

Be explicit: combine subject, environment, lighting, and camera, for example "Studio photo of a red ceramic mug, softbox lighting, 50mm, shallow depth of field." Set aspect_ratio intentionally: 9:16 for stories, 16:9 for cinematic, 1:1 for feeds. Switch output_format to png for crisp edges and text. Keep thinking_level on high for complex prompts and minimal for the fastest drafts. Reuse a seed to reproduce a composition, and pass image_urls to anchor style or edit an existing image.

FAQs

Is Nano Banana 2 Lite open-source? No. It is a hosted Google model (Gemini 3.1 Flash-Lite Image) accessed via API.

Can it edit images or only generate them? Both. It supports text-to-image, image editing, and multi-image composition through image_urls.

What resolution does it output? Outputs are generated at 1K resolution; higher 2K or 4K canvases are not supported on Lite.

How is it different from Nano Banana 2 and Pro? Lite is speed-first; Nano Banana 2 is the generalist workhorse; Nano Banana Pro targets complex, high-fidelity work.

Are outputs watermarked? Yes. Every image carries an invisible SynthID watermark identifying it as AI-generated.

Can I generate non-square images for ads and video? Yes. Choose from 15 aspect ratios including 16:9, 9:16, 21:9, and ultra-wide formats.