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
26
const axios = require('axios');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/nano-banana-2";
const data = {
"seed": 420875,
"prompt": "A professional photograph of a beautifully crafted hand-painted gold leaf sign on a glass window pane. The central focus is the text 'MEXITALY' rendered in an elegant, red and gold script font. Below it, in larger, bold, gold beveled letters with a deep red shadow and gold outline, are the words 'TORNABUONI'. Underneath, in smaller, teal and cream script lettering, is 'Strada64', followed by 'BarandRestaurant' on the final line in the same teal and cream script style. The entire text composition is framed by intricate gold and teal decorative flourishes and stylized star motifs. The reflection of a warm, bustling European street, specifically Via de' Tornabuoni in Florence with its historic architecture and pedestrian crowds at twilight, is visible through the glass pane, adding depth to the image. The glass itself has a slight texture. The perspective is a straight-on medium shot, capturing the details of the lettering and the atmospheric reflection.",
"web_search": false,
"aspect_ratio": "1:1",
"output_format": "jpg",
"thinking_level": "minimal",
"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 seed for reproducible outputs. Same seed yields similar images.
Image Prompt
Reference image URLs for style guidance. Up to 14 images.
Enable for real-time data. Recommended for news-related prompts.
Image shape. Auto lets model decide, 16:9 for cinematic.
Allowed values:
Image file type. PNG for quality, WebP for web optimization.
Allowed values:
Reasoning depth. High for complex prompts, minimal for fast output.
Allowed values:
Content moderation level. 1 = strictest, 6 = least strict.
Allowed values:
Determine image clarity. Select '2K' for clarity in digital presentations.
Allowed values:
Output type. IMAGE for image-only, TEXT_AND_IMAGE for both.
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 is Google’s latest generative AI image model built for fast, high-fidelity text-to-image generation with strong photorealism, better world knowledge, and optional real-time web search grounding. It’s designed for teams who need production-ready visuals without slow iteration cycles—think rapid concepting, ad creatives, and consistent subject renders across a set.
Compared to typical image generators, Nano Banana 2 emphasizes instruction following (getting the details right), consistent subject appearance across multiple outputs, and flexible delivery options for aspect ratios, resolutions, and file formats. You can also pass reference images to guide composition or style.
image_urls for style or subject cuesweb_search for prompts requiring current factsimage_urls to anchor style (e.g., “in the style of the reference image”) or composition.aspect_ratio intentionally: 9:16 for mobile stories, 16:9 for cinematic, 1:1 for feeds.output_resolution to 2K/4K for sharper typography-like details and crop flexibility.web_search=true when generating images tied to current events or specific real-world entities.Is Nano Banana 2 open-source?
No—Nano Banana 2 is a hosted Google model exposed via API-style parameters.
How is it different from other text-to-image models?
It’s optimized for speed + photorealism, with improved instruction following, subject consistency, and optional web-grounded accuracy.
What parameters should I tweak for best results?
Start with aspect_ratio, then raise output_resolution for detail, switch output_format to png for crisp edges, and use image_urls for tighter control.
When should I enable web_search?
Use it for prompts requiring up-to-date context or accurate rendering of specific real-world subjects.
Can I generate non-square images for ads and video?
Yes—choose from many aspect_ratio options including 16:9, 9:16, 21:9, and ultra-wide formats.