Nano Banana 2 Serverless API
Nano Banana 2 rapidly generates photorealistic images from text prompts, ideal for marketing and creative projects.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/nano-banana-2"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "seed": 420875,
12 "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.",
13 "image_urls": [],
14 "web_search": false,
15 "aspect_ratio": "1:1",
16 "output_format": "jpg",
17 "thinking_level": "minimal",
18 "safety_tolerance": 4,
19 "output_resolution": "1K",
20 "response_modalities": "TEXT_AND_IMAGE"
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26 result = response.json()
27 print(json.dumps(result, indent=2))
28else:
29 print(f"Error: {response.status_code}")
30 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/nano-banana-2"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "seed": 420875,
12 "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.",
13 "image_urls": [],
14 "web_search": false,
15 "aspect_ratio": "1:1",
16 "output_format": "jpg",
17 "thinking_level": "minimal",
18 "safety_tolerance": 4,
19 "output_resolution": "1K",
20 "response_modalities": "TEXT_AND_IMAGE"
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26 result = response.json()
27 print(json.dumps(result, indent=2))
28else:
29 print(f"Error: {response.status_code}")
30 print(response.text)API Endpoint
https://api.segmind.com/v1/nano-banana-2Parameters
promptrequiredstringImage 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."aspect_ratiooptionalstringChoose image shape. Use 'auto' to let the model decide, '16:9' for cinematic views.
"1:1""auto""1:1""2:3""3:2""4:3""3:4""4:5""5:4""16:9""9:16"+5 moreimage_urlsoptionalstring[]Provide URLs for reference images (up to 14). Use classic art URLs for artistic outcomes.
output_formatoptionalstringSelect image file type. Use 'png' for detailed imagery, 'webp' for web optimization.
"jpg""jpg""png"output_resolutionoptionalstringDetermine image clarity. Select '2K' for clarity in digital presentations.
"1K""512px""1K""2K""4K"response_modalitiesoptionalstringControl output type. Use IMAGE for image-only output, TEXT_AND_IMAGE for both text and image.
"TEXT_AND_IMAGE""TEXT_AND_IMAGE""IMAGE"safety_toleranceoptionalintegerContent moderation level. 1 = strictest, 6 = least strict.
4123456seedoptionalintegerRandom seed for reproducible results. Use the same seed to generate similar images.
420875thinking_leveloptionalstringControl reasoning depth. Use 'high' for complex prompts requiring more reasoning, 'minimal' for faster generation.
"minimal""minimal""high"web_searchoptionalbooleanEnable for real-time data. Recommended for news-related prompts.
falseResponse Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out