Skip to main content
POST
/
v1beta
/
models
/
gemini-2.5-flash-image:generateContent
Text to Image
curl --request POST \
  --url https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "contents": [
    {
      "parts": [
        {
          "text": "<string>"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "<string>"
    ],
    "imageConfig": {
      "aspectRatio": "<string>"
    }
  }
}'
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}

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.

Supported inputs & outputs :

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

contents
array
required
generationConfig
object

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 ratioResolution
1:11024x1024
2:3832x1248
3:21248x832
3:4864x1184
4:31184x864
4:5896x1152
5:41152x896
9:16768x1344
16:91344x768
21:91536x672

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"
}
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}