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 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); } })();
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: 420875 )

Random seed for reproducible outputs. Same seed yields similar images.


promptstr *

Image Prompt


image_urlsstr ( default: 1 )

Reference image URLs for style guidance. Up to 14 images.


web_searchbool ( default: 1 ) Affects Pricing

Enable for real-time data. Recommended for news-related prompts.


aspect_ratioenum:str ( default: 1:1 )

Image shape. Auto lets model decide, 16:9 for cinematic.

Allowed values:


output_formatenum:str ( default: jpg )

Image file type. PNG for quality, WebP for web optimization.

Allowed values:


thinking_levelenum:str ( default: minimal )

Reasoning depth. High for complex prompts, minimal for fast output.

Allowed values:


safety_toleranceenum:int ( default: 4 )

Content moderation level. 1 = strictest, 6 = least strict.

Allowed values:


output_resolutionenum:str ( default: 1K ) Affects Pricing

Determine image clarity. Select '2K' for clarity in digital presentations.

Allowed values:


response_modalitiesenum:str ( default: TEXT_AND_IMAGE )

Output type. IMAGE for image-only, TEXT_AND_IMAGE for both.

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: Text-to-Image Model

What is Nano Banana 2?

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.

Key Features

  • Photorealistic image generation with strong detail and lighting fidelity
  • Reference-image guidance via image_urls for style or subject cues
  • Search-grounded generation with web_search for prompts requiring current facts
  • Consistent subject rendering across iterations (useful for campaigns and storyboards)
  • Production-friendly outputs: multiple aspect ratios, up to 4K, JPG/PNG
  • Fast iteration for rapid edits and creative exploration

Best Use Cases

  • Marketing & ads: product scenes, lifestyle imagery, Google Ads-style variants
  • E-commerce & retail: hero images, seasonal collections, consistent product look
  • Media & publishing: editorial illustrations with optional web-grounded accuracy
  • UX/UI & product teams: concept art, onboarding visuals, placeholder imagery
  • Creators & studios: story frames, thumbnails, cinematic compositions (16:9, 21:9)

Prompt Tips and Output Quality

  • Be explicit: subject + environment + lighting + camera. Example: “Studio photo of a red ceramic mug, softbox lighting, 50mm, shallow depth of field.”
  • For consistency, repeat key identifiers (wardrobe, colors, props) across prompts.
  • Use image_urls to anchor style (e.g., “in the style of the reference image”) or composition.
  • Pick aspect_ratio intentionally: 9:16 for mobile stories, 16:9 for cinematic, 1:1 for feeds.
  • Increase output_resolution to 2K/4K for sharper typography-like details and crop flexibility.
  • Enable web_search=true when generating images tied to current events or specific real-world entities.

FAQs

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.