# Nano Banana 2 > Nano Banana 2 rapidly generates photorealistic images from text prompts, ideal for marketing and creative projects. ## Overview - **Endpoint**: `https://api.segmind.com/v1/nano-banana-2` - **Model ID**: `nano-banana-2` - **Category**: Image-to-Image Transformation - **Type**: Synchronous (Direct response) - **Average Cost**: $0.08887874646896693 ## Pricing | output_resolution | web_search | cost | | --- | --- | --- | | 512px | false | 0.06 | | 512px | true | 0.075 | | 1K | false | 0.08 | | 1K | true | 0.095 | | 2K | false | 0.12 | | 2K | true | 0.135 | | 4K | false | 0.16 | | 4K | true | 0.175 | ## API Information This model uses a **synchronous response pattern**: 1. Make a POST request with your parameters 2. Receive the output directly in the response (binary for images/videos/audio, JSON for text) 3. No polling required - response is immediate ### Input Schema The API accepts the following input parameters: - **`prompt`** (`string`, _required_): Prompt Describe the image to generate or the changes to make to the reference images. - Default: `"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."` - **`image_urls`** (`array`, _optional_): Reference images Optional reference images for style guidance. Nano Banana 2 accepts up to 14 images. - Default: `[]` - Item type: string - **`system_prompt`** (`string`, _optional_): System prompt Optional high-level persona or style instructions applied to the generation. - Default: `""` - **`aspect_ratio`** (`string`, _optional_): Aspect ratio Choose the proportions of the generated image. "Auto" lets the model pick. - Default: `"1:1"` - Options: "auto" (Auto (model decides)), "1:1" (Square (1:1)), "2:3" (Portrait (2:3)), "3:2" (Landscape (3:2)), "4:3" (Landscape (4:3)), "3:4" (Portrait (3:4)), "4:5" (Portrait (4:5)), "5:4" (Landscape (5:4)), "16:9" (Widescreen (16:9)), "9:16" (Vertical (9:16)), "21:9" (Ultrawide (21:9)), "4:1" (Wide (4:1)), "1:4" (Tall (1:4)), "8:1" (Very wide (8:1)), "1:8" (Very tall (1:8)) - **`output_resolution`** (`string`, _optional_): Output resolution Output detail level. Also determines the price tier. - Default: `"1K"` - Options: "512px" (512px), "1K" (1K), "2K" (2K), "4K" (4K (highest detail)) - **`output_format`** (`string`, _optional_): Output format File format of the generated image. - Default: `"jpg"` - Options: "jpg" (JPG), "png" (PNG) - **`web_search`** (`boolean`, _optional_): Web search Ground generation in real-time web data. Recommended for news-related prompts. Also affects price. - Default: `false` - **`response_modalities`** (`string`, _optional_): Response format Return only the generated image or include a text response alongside it. - Default: `"TEXT_AND_IMAGE"` - Options: "TEXT_AND_IMAGE" (Text and image), "IMAGE" (Image only) - **`seed`** (`integer`, _optional_): Seed Seed for reproducible results. - Default: `420875` - Range: 0 to 999999999999999 - **`thinking_level`** (`string`, _optional_): Thinking level Reasoning depth. High for complex prompts, minimal for fast output. - Default: `"minimal"` - Options: "minimal" (Minimal), "high" (High) - **`safety_tolerance`** (`integer`, _optional_): Safety tolerance Content moderation level, 1 (strictest) to 6 (least strict). - Default: `4` - Options: "1" (1 (Strictest)), "2" (2), "3" (3), "4" (4), "5" (5), "6" (6 (Least strict)) **Required Parameters Example**: ```json { "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." } ``` **Full Example**: ```json { "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.", "image_urls": [], "system_prompt": "", "aspect_ratio": "1:1", "output_resolution": "1K", "output_format": "jpg", "web_search": false, "response_modalities": "TEXT_AND_IMAGE", "seed": 420875, "thinking_level": "minimal", "safety_tolerance": 4 } ``` ### Output Schema The API returns a synchronous response based on the model type: **For Image/Video/Audio Models**: - Response contains binary data (image/png, video/mp4, audio/mp3) - Content-Type header indicates the media type - Save the response body directly to a file **For Text Models**: - Response is JSON with the generated text - Structure varies by model **HTTP Response Codes**: - **200 - OK**: Request successful, output in response body - **400 - Bad Request**: Invalid parameters - **401 - Unauthorized**: Invalid or missing API key - **404 - Not Found**: Model not found - **406 - Not Acceptable**: Insufficient credits - **429 - Too Many Requests**: Rate limit exceeded - **500 - Server Error**: Internal server error ## Usage Examples ### cURL ```bash curl -X POST "https://api.segmind.com/v1/nano-banana-2" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "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.", "image_urls": [], "system_prompt": "", "aspect_ratio": "1:1", "output_resolution": "1K", "output_format": "jpg", "web_search": false, "response_modalities": "TEXT_AND_IMAGE", "seed": 420875, "thinking_level": "minimal", "safety_tolerance": 4 }' ``` ### Python ```python import requests import json api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/nano-banana-2" data = { "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.", "image_urls": [], "system_prompt": "", "aspect_ratio": "1:1", "output_resolution": "1K", "output_format": "jpg", "web_search": false, "response_modalities": "TEXT_AND_IMAGE", "seed": 420875, "thinking_level": "minimal", "safety_tolerance": 4 } response = requests.post( url, json=data, headers={ 'x-api-key': api_key, 'Content-Type': 'application/json' } ) if response.status_code == 200: # For image/video/audio models, response.content contains the binary data with open('output.png', 'wb') as f: f.write(response.content) print('Generation complete, saved to output.png') else: print(f"Error: {response.status_code}") print(response.text) ``` ### JavaScript ```javascript const apiKey = 'YOUR_API_KEY'; const url = 'https://api.segmind.com/v1/nano-banana-2'; const data = { "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.", "image_urls": [], "system_prompt": "", "aspect_ratio": "1:1", "output_resolution": "1K", "output_format": "jpg", "web_search": false, "response_modalities": "TEXT_AND_IMAGE", "seed": 420875, "thinking_level": "minimal", "safety_tolerance": 4 }; const response = await fetch(url, { method: 'POST', headers: { 'x-api-key': apiKey, 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); if (response.ok) { // For image/video/audio models, response contains binary data const blob = await response.blob(); const downloadUrl = URL.createObjectURL(blob); // Create download link const a = document.createElement('a'); a.href = downloadUrl; a.download = 'output.png'; a.click(); console.log('Generation complete'); } ``` ## Additional Resources ### Documentation - [Model Playground](https://www.segmind.com/models/nano-banana-2) - [API Documentation](https://www.segmind.com/models/nano-banana-2/api) - [Pricing Details](https://www.segmind.com/models/nano-banana-2/pricing) - [Platform Documentation](https://docs.segmind.com/) ### Tags No tags available