Gemini 2.5 Flash Image (Nano Banana)
Model Overview
Google’s smartest image generation model as of August 2025.
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.
API Schema
post
Authorizations
AuthorizationstringRequired
Bearer key
Body
modelundefined · enumRequiredPossible values:
promptstringRequired
The text prompt describing the content, style, or composition of the image to be generated.
num_imagesnumber · min: 1 · max: 4OptionalDefault:
The number of images to generate.
1Responses
201
Successfully generated image
application/json
post
/v1/images/generationsasync function main() {
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'google/gemini-2.5-flash-image',
prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
}),
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
}
main();201
Successfully generated image
{
"data": [
{
"url": "text",
"b64_json": "text"
}
]
}Quick Example
Let's generate an image of the specified aspect ratio using a simple prompt.
import requests
import json
def main():
response = requests.post(
"https://api.aimlapi.com/v1/images/generations",
headers={
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
"Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type": "application/json",
},
json={
"model": "google/gemini-2.5-flash-image",
"prompt": "Racoon eating ice-cream"
}
)
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()async function main() {
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
method: 'POST',
headers: {
// Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'google/gemini-2.5-flash-image',
prompt: 'Racoon eating ice-cream',
aspect_ratio: '16:9'
}),
});
const data = await response.json();
console.log(data);
}
main();So we obtained the following 1024x1024 image by running this code example:

Last updated
Was this helpful?