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);
}
})();Random integer seeding generation for reproducibility. Reuse a value to reproduce an image.
Text description of the image to generate; required. Be specific about subject, lighting, camera.
Optional reference image URLs for editing or multi-image composition. Add up to 14.
Output shape from 15 presets; default 1:1. Use 16:9 cinematic, 9:16 mobile, auto adaptive.
Allowed values:
File type, jpg or png; default jpg. Choose png for sharper edges and text.
Allowed values:
Reasoning depth, minimal or high; default high. Use high for complex prompts, minimal faster.
Allowed values:
Content moderation strictness from 1 to 6; default 4. Lower is stricter, higher permissive.
Allowed values:
Image resolution; only 1K is supported. Leave at 1K for every generation.
Allowed values:
Return IMAGE only or TEXT_AND_IMAGE; default TEXT_AND_IMAGE. Use IMAGE to skip text output.
Allowed values:
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 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).
image_urls to edit or blend up to 14 inputs1:1 feeds to 16:9 cinematic and 9:16 mobileIMAGE only or TEXT_AND_IMAGEBe 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.
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.