Skip to main content
POST
/
v1beta
/
models
/
gemini-2.5-flash-image-preview-hd:generateContent
gemini-2.5-flash-image-preview-hd (Image Edit)
curl --request POST \
  --url https://api.example.com/v1beta/models/gemini-2.5-flash-image-preview-hd:generateContent

API Key Authentication

GPTProto API uses Bearer token authentication. All API requests must include your API key (sk-xxxxx) in the Authorization header.

Getting Your API Key

  1. Sign up for a GPTProto account at https://gptproto.com
  2. Navigate to the API Keys section in your dashboard
  3. Generate a new API key
  4. Copy and securely store your API key For authentication details, please refer to the Authentication section.

Initiate Request

curl --location --request POST 'https://gptproto.com/v1beta/models/gemini-2.5-flash-image-preview-hd:generateContent' \
--header 'Authorization: GPTPROTO_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Put a hat on the cat"
                },
                {
                    "fileData": {
                        "mimeType": "image/png",
                        "fileUri": "https://tos.gptproto.com/resource/cat.png"
                    }
                }
            ]
        }
    ]
}'

Response Example

{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/jpeg",
              "data": "base64_encode_data"
            }
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 7,
    "candidatesTokenCount": 1202,
    "totalTokenCount": 1347,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 7
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "IMAGE",
        "tokenCount": 1120
      }
    ],
    "thoughtsTokenCount": 138
  },
  "modelVersion": "gemini-2.5-flash-image-preview-hd",
  "responseId": "rUhKaeiQJceM-sAP5p7bsAo"
}

Parameters

Core Parameters

ParameterTypeRequiredDefaultRangeDescription
contentsarray✅ Yes--Content of the current conversation with the model. For single-turn queries, this contains one instance. For multi-turn queries (e.g., chat), this contains the conversation history and the latest request.
>contents.rolestring✅ Yes-user
model
The role of the message sender.
>contents.partsarray✅ Yes--The content parts of the message, which can contain different types of content (text, inlineData, etc.).
>>contents.parts.textstring✅ Yes--The prompt for generating images. To include images or multiple images, refer to Multimodal Input.
generation_configobject❌ No--Configuration options for content generation.
>generation_config.image_configobject❌ No--Configuration for image generation. If set for models that don’t support these configuration options, the system will return an error. See Image Config for details.
>generation_config.response_modalitiesarray❌ No-TEXT
IMAGE
The modalities of the response. If set for models that don’t support these configuration options, the system will return an error.

Multimodal Input

{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "inline_data": {
            "mime_type": "image/jpeg",
            "data": "base64-encoded-image-data"
          }
        },
        {
          "text": "a cat"
        }
      ]
    }
  ]
}
parameterTypeRequiredDefaultRange / ExampleDescription
contents.partsarray✅ Yestext
inlineData
fileData
The content parts of the message, which can contain different types of content .
>contents.parts.inlineDataobject❌ No--Inline media content. If used, data must be base64-encoded.
>>contents.parts.inlineData.mimeTypestring✅ Yes (if inline_data is used)-image/png
image/jpeg
The IANA-standard MIME type of the source data. If the provided MIME type is not supported, the system will return an error.
>>contents.parts.inlineData.datastring✅ Yes (if inline_data is used)--Base64-encoded media data.
>contents.parts.fileDataobject❌ No--File media content. If used, fileUri must be provided.
>>contents.parts.fileData.mimeTypestring✅ Yes (if file_data is used)-image/png
image/jpeg
The IANA-standard MIME type of the source data. If the provided MIME type is not supported, the system will return an error.
>>contents.parts.fileData.fileUristring✅ Yes (if file_data is used)--The URI of the file to be processed.

Image Config

{
  "generation_config": {
    "image_config": {
      "aspect_ratio": "1:1",
      "image_size": "1k"
    }
  }
}
parameterTypeRequiredDefaultRange / ExampleDescription
image_configobject❌ No--Configuration for image generation.
>image_config.aspect_ratiostring❌ No-1:1
2:3
3:2
3:4
4:3
9:16
16:9
21:9
Aspect ratio of the generated image. If not specified, the model will select the appropriate aspect ratio based on the specified content.
>image_config.image_sizestring❌ No-1K
2K
4K
Approximate size of the generated image. If not specified, the model will use the default value of 1K. only Gemini 3 Pro Image Preview,

Differences between using gemini2.5 and gemini3

Note: With Gemini 3 Pro Image Preview, you can reference up to 14 images in a single request.
  • Up to 6 high-fidelity object images can be supplied for inclusion in the final output.
  • Up to 5 portrait photos can be provided to maintain character consistency.
    By contrast, Gemini 2.5 Flash Image supports a maximum of 3 reference images.

Aspect Ratio & Image Size

By default, the model keeps the output image the same size as the input image; otherwise it produces a 1:1 square.
You can control the aspect ratio of the generated image with the aspect_ratio field under image_config in your request, as shown below:
Gemini 2.5 Flash Image
Aspect ratioResolutionTokens
1:11024x10241290
2:3832x12481290
3:21248x8321290
3:4864x11841290
4:31184x8641290
4:5896x11521290
5:41152x8961290
9:16768x13441290
16:91344x7681290
21:91536x6721290
Gemini 3 Pro Image Preview
Aspect ratio1K resolution1K tokens2K resolution2K tokens4K resolution4K tokens
1:11024x102411202048x204811204096x40962000
2:3848x126411201696x252811203392x50562000
3:21264x84811202528x169611205056x33922000
3:4896x120011201792x240011203584x48002000
4:31200x89611202400x179211204800x35842000
4:5928x115211201856x230411203712x46082000
5:41152x92811202304x185611204608x37122000
9:16768x137611201536x275211203072x55042000
16:91376x76811202752x153611205504x30722000
21:91584x67211203168x134411206336x26882000

Error Codes

Common Error Codes

Error CodeError NameDescription
401UnauthorizedAPI key is missing or invalid
403ForbiddenYour API key doesn’t have permission to access this resource, or insufficient balance for the requested operation
429Too Many RequestsYou’ve exceeded your rate limit
500Internal server errorAn internal server error occurred
503Content policy violationContent blocked due to safety concerns (actual status code is 400)