Nano Banana Serverless API
Gemini Image Editor preserves authentic subject identity while enabling seamless image editing and manipulation.
~14.28s
$0.04 per generation
1import requests
2import json
3
4url = "https://api.segmind.com/v1/nano-banana"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Dancing Banana",
12 "image_urls": [
13 "https://segmind-inference-inputs.s3.amazonaws.com/5ead6a2e-3e8d-4d07-a86d-5777fc6cb6f9-09a99645-3171-4742-be08-dfcfe7f0a4b2-1304f734-929b-4047-822d-4f59fca2179a-40457f0b-d422-4525-b3a5-19633a9cdac0.png"
14 ],
15 "aspect_ratio": "1:1",
16 "response_modalities": "TEXT_AND_IMAGE"
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/nano-banana"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Dancing Banana",
12 "image_urls": [
13 "https://segmind-inference-inputs.s3.amazonaws.com/5ead6a2e-3e8d-4d07-a86d-5777fc6cb6f9-09a99645-3171-4742-be08-dfcfe7f0a4b2-1304f734-929b-4047-822d-4f59fca2179a-40457f0b-d422-4525-b3a5-19633a9cdac0.png"
14 ],
15 "aspect_ratio": "1:1",
16 "response_modalities": "TEXT_AND_IMAGE"
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text)API Endpoint
POST
https://api.segmind.com/v1/nano-bananaParameters
promptrequiredstringPrompt to render
Default:
"Dancing Banana"aspect_ratiooptionalstringDetermines image proportions. Select '16:9' for widescreen, '1:1' for square format.
Default:
"1:1"Allowed values :
"1:1""2:3""3:2""4:3""3:4""4:5""5:4""16:9""9:16""21:9"image_urlsoptionalstring[]A list of image urls.
response_modalitiesoptionalstringControl output type. Use IMAGE for image-only output, TEXT_AND_IMAGE for both text and image.
Default:
"TEXT_AND_IMAGE"Allowed values :
"TEXT_AND_IMAGE""IMAGE"Response Type
Returns: Text/JSON
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
400
Bad Request
Invalid parameters or request format
401
Unauthorized
Missing or invalid API key
403
Forbidden
Insufficient permissions
404
Not Found
Model or endpoint not found
406
Insufficient Credits
Not enough credits to process request
429
Rate Limited
Too many requests
500
Server Error
Internal server error
502
Bad Gateway
Service temporarily unavailable
504
Timeout
Request timed out