Overview
Google Gemini 2.5 Flash Image, a powerful new image generation and editing model with advanced features and creative control.
Text-to-Image: Generate high-quality images from simple or complex text descriptions.
Inputs: Text
Outputs: Text and image
Authentication
This endpoint requires authentication using a Bearer token.
Authorization
string
default: "sk-***********"
required
Your API key in the format: YOUR_API_KEY
Request Body
The prompt for the generation.
The model defaults to returning text and image responses (['Text', 'Image']). You can configure the response to return only images without text using ( ['Image']).
1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. default 1:1
Text-to-Image
curl -X POST "https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent" \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts":[
{"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
]
}],
"generationConfig": {
"responseModalities": ["Text", "Image"],
"imageConfig": {"aspectRatio": "1:1"}
}
}'
Aspect ratios
The model defaults to generates 1:1 squares. You can control the aspect ratio of the output image using the aspect_ratio field under image_config in the response request: The different ratios available and the size of the image generated are listed in this table:
Aspect ratio Resolution
1:1 1024x1024 2:3 832x1248 3:2 1248x832 3:4 864x1184 4:3 1184x864 4:5 896x1152 5:4 1152x896 9:16 768x1344 16:9 1344x768 21:9 1536x672
Response
{
"candidates" : [
{
"content" : {
"role" : "model" ,
"parts" : [
{
"inlineData" : {
"mimeType" : "image/png" ,
"data" : "image base64"
}
}
]
},
"finishReason" : "STOP"
}
],
"usageMetadata" : {
"promptTokenCount" : 16 ,
"candidatesTokenCount" : 1290 ,
"totalTokenCount" : 1306 ,
"thoughtsTokenCount" : 0 ,
"promptTokensDetails" : [
{
"modality" : "TEXT" ,
"tokenCount" : 16
}
]
},
"modelVersion" : "gemini-2.5-flash-image"
}
401 - Invalid signature
403 - Invalid Token
403 - Insufficient balance
500 - Internal server error
503 - Content policy violation
{
"error" : {
"message" : "Invalid signature" ,
"type" : "401"
}
}