Gemini-2.5-Flash-Image - Image Edit
Smart gemini 2.5 flash image edit tools. Effortless AI-powered photo retouching and creative editing on the fly.
POST
/
v1beta
/
models
/
gemini-2.5-flash-image:generateContent
gemini-2.5-flash-image (Image Edit)
curl --request POST \
--url https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContentimport requests
url = "https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent")
.asString();require 'uri'
require 'net/http'
url = URI("https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuthentication
- Sign up for a GPTProto account at https://gptproto.com
- Navigate to the API Keys section in your dashboard
- Generate a new API key (sk-xxxxx)
- Copy and securely store your API key For authentication details, please refer to the Authentication section.
Initiate Request
curl --location 'https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent' \
--header 'Authorization: GPTPROTO_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Put a hat on the cat"
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://tos.gptproto.com/resource/cat.png"
}
}
]
}
],
"generationConfig": {
"imageConfig": {
"aspectRatio": "1:1"
}
}
}'
const axios = require('axios');
let data = JSON.stringify({
"contents": [
{
"role": "user",
"parts": [
{
"text": "Put a hat on the cat"
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://tos.gptproto.com/resource/cat.png"
}
}
]
}
],
"generationConfig": {
"imageConfig": {
"aspectRatio": "1:1"
}
}
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent',
headers: {
'Authorization': 'GPTPROTO_API_KEY',
'Content-Type': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import requests
import json
url = "https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent"
payload = json.dumps({
"contents": [
{
"role": "user",
"parts": [
{
"text": "Put a hat on the cat"
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://tos.gptproto.com/resource/cat.png"
}
}
]
}
],
"generationConfig": {
"imageConfig": {
"aspectRatio": "1:1"
}
}
})
headers = {
'Authorization': 'GPTPROTO_API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gptproto.com/v1beta/models/gemini-2.5-flash-image:generateContent"
method := "POST"
payload := strings.NewReader(`{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Put a hat on the cat"
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://tos.gptproto.com/resource/cat.png"
}
}
]
}
],
"generationConfig": {
"imageConfig": {
"aspectRatio": "1:1"
}
}
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "GPTPROTO_API_KEY")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Response Example
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-3-pro-image-preview",
"responseId": "rUhKaeiQJceM-sAP5p7bsAo"
}
Parameters
Core Parameters
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
contents | array | ✅ 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.role | string | ✅ Yes | - | usermodel | The role of the message sender. |
>contents.parts | array | ✅ Yes | - | - | The content parts of the message, which can contain different types of content (text, inlineData, etc.). |
>>contents.parts.text | string | ✅ Yes | - | - | The prompt for generating images. To include images or multiple images, refer to Multimodal Input. |
generationConfig | object | ❌ No | - | - | Configuration options for content generation. |
>generationConfig.imageConfig | object | ❌ 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. |
>generationConfig.responseModalities | array | ❌ No | - | TEXTIMAGE | The modalities of the response. If set for models that don’t support these configuration options, the system will return an error. |
>generationConfig.temperature | number | ❌ No | - | 0.0-1.0 | Controls the randomness of the output. |
Multimodal Input
{
"contents": [
{
"role": "user",
"parts": [
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "base64-encoded-image-data"
}
},
{
"text": "a cat"
}
]
}
]
}
{
"contents": [
{
"role": "user",
"parts": [
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "base64-encoded-image-1-data"
}
},
{
"inlineData": {
"mimeType": "image/png",
"data": "base64-encoded-image-2-data"
}
},
{
"text": "Combine these two images into a seamless panorama with a mountain background."
}
]
}
]
}
{
"contents": [
{
"role": "user",
"parts": [
{
"fileData": {
"mimeType": "image/jpeg",
"fileUri": "https://example.com/image.jpg"
}
},
{
"text": "a cat"
}
]
}
]
}
{
"contents": [
{
"role": "user",
"parts": [
{
"fileData": {
"mimeType": "image/jpeg",
"fileUri": "https://example.com/image1.jpg"
}
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://example.com/image2.png"
}
},
{
"text": "Remove the background from both images and blend them together with a sunset overlay."
}
]
}
]
}
| parameter | Type | Required | Default | Range / Example | Description | |
|---|---|---|---|---|---|---|
contents.parts | array | ✅ Yes | — | textinlineDatafileData | The content parts of the message, which can contain different types of content . | |
>contents.parts.inlineData | object | ❌ No | - | - | Inline media content. If used, data must be base64-encoded. | |
>>contents.parts.inlineData.mimeType | string | ✅ Yes (if inline_data is used) | - | image/pngimage/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.data | string | ✅ Yes (if inline_data is used) | - | - | Base64-encoded media data. | |
>contents.parts.fileData | object | ❌ No | - | - | File media content. If used, fileUri must be provided. | |
>>contents.parts.fileData.mimeType | string | ✅ Yes (if file_data is used) | - | image/pngimage/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.fileUri | string | ✅ Yes (if file_data is used) | - | - | The URI of the file to be processed. |
Image Config
{
"generationConfig": {
"imageConfig": {
"aspectRatio": "1:1",
"imageSize": "1K"
}
}
}
| parameter | Type | Required | Default | Range / Example | Description |
|---|---|---|---|---|---|
imageConfig | object | ❌ No | - | - | Configuration for image generation. |
>imageConfig.aspectRatio | string | ❌ No | - | 1:12:33:23:44:39:1616:921:91:44:11:88:1 | Aspect ratio of the generated image. If not specified, the model will select the appropriate aspect ratio based on the specified content. 1:4, 4:1, 1:8, 8:1 are only supported by Gemini 3.1 Flash Image Preview. |
>imageConfig.imageSize | string | ❌ No | - | 0.5K1K2K4K | Approximate size of the generated image. If not specified, the model will use the default value of 1K. 0.5K is only supported by Gemini 3.1 Flash Image Preview; 2K and 4K are only supported by Gemini 3.1 Flash Image Preview and Gemini 3 Pro Image Preview. |
Model Comparison
| Feature | Gemini 2.5 Flash Image | Gemini 3.1 Flash Image Preview | Gemini 3 Pro Image Preview |
|---|---|---|---|
| Use case | Speed & efficiency | Speed & high-volume | Professional asset production |
| Supported sizes | 1K | 0.5K, 1K, 2K, 4K | 1K, 2K, 4K |
| Max reference images | 3 | 14 | 14 |
| Max object images | — | 10 | 6 |
| Max portrait images | — | 4 | 5 |
| Extra aspect ratios | — | 1:4, 4:1, 1:8, 8:1 | — |
| Google Image Search Grounding | — | ✅ | — |
- Gemini 3.1 Flash Image Preview: Optimized for speed and high-volume use cases. Supports 0.5K resolution and extra ultra-wide/tall aspect ratios (1:4, 4:1, 1:8, 8:1). Also supports Google Image Search Grounding.
- Gemini 3 Pro Image Preview: Optimized for professional asset production with advanced reasoning for complex creation tasks.
- Gemini 2.5 Flash Image: Supports a maximum of 3 reference images and 1K resolution only.
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 theaspect_ratio field under image_config in your request, as shown below:
Gemini 2.5 Flash Image
| Aspect ratio | Resolution | Tokens |
|---|---|---|
| 1:1 | 1024x1024 | 1290 |
| 2:3 | 832x1248 | 1290 |
| 3:2 | 1248x832 | 1290 |
| 3:4 | 864x1184 | 1290 |
| 4:3 | 1184x864 | 1290 |
| 4:5 | 896x1152 | 1290 |
| 5:4 | 1152x896 | 1290 |
| 9:16 | 768x1344 | 1290 |
| 16:9 | 1344x768 | 1290 |
| 21:9 | 1536x672 | 1290 |
| Aspect ratio | 512px resolution | 0.5K tokens | 1K resolution | 1K tokens | 2K resolution | 2K tokens | 4K resolution | 4K tokens |
|---|---|---|---|---|---|---|---|---|
| 1:1 | 512x512 | 747 | 1024x1024 | 1120 | 2048x2048 | 1120 | 4096x4096 | 2000 |
| 1:4 | 256x1024 | 747 | 512x2048 | 1120 | 1024x4096 | 1120 | 2048x8192 | 2000 |
| 1:8 | 192x1536 | 747 | 384x3072 | 1120 | 768x6144 | 1120 | 1536x12288 | 2000 |
| 2:3 | 424x632 | 747 | 848x1264 | 1120 | 1696x2528 | 1120 | 3392x5056 | 2000 |
| 3:2 | 632x424 | 747 | 1264x848 | 1120 | 2528x1696 | 1120 | 5056x3392 | 2000 |
| 3:4 | 448x600 | 747 | 896x1200 | 1120 | 1792x2400 | 1120 | 3584x4800 | 2000 |
| 4:1 | 1024x256 | 747 | 2048x512 | 1120 | 4096x1024 | 1120 | 8192x2048 | 2000 |
| 4:3 | 600x448 | 747 | 1200x896 | 1120 | 2400x1792 | 1120 | 4800x3584 | 2000 |
| 4:5 | 464x576 | 747 | 928x1152 | 1120 | 1856x2304 | 1120 | 3712x4608 | 2000 |
| 5:4 | 576x464 | 747 | 1152x928 | 1120 | 2304x1856 | 1120 | 4608x3712 | 2000 |
| 8:1 | 1536x192 | 747 | 3072x384 | 1120 | 6144x768 | 1120 | 12288x1536 | 2000 |
| 9:16 | 384x688 | 747 | 768x1376 | 1120 | 1536x2752 | 1120 | 3072x5504 | 2000 |
| 16:9 | 688x384 | 747 | 1376x768 | 1120 | 2752x1536 | 1120 | 5504x3072 | 2000 |
| 21:9 | 792x336 | 747 | 1584x672 | 1120 | 3168x1344 | 1120 | 6336x2688 | 2000 |
| Aspect ratio | 1K resolution | 1K tokens | 2K resolution | 2K tokens | 4K resolution | 4K tokens |
|---|---|---|---|---|---|---|
| 1:1 | 1024x1024 | 1120 | 2048x2048 | 1120 | 4096x4096 | 2000 |
| 2:3 | 848x1264 | 1120 | 1696x2528 | 1120 | 3392x5056 | 2000 |
| 3:2 | 1264x848 | 1120 | 2528x1696 | 1120 | 5056x3392 | 2000 |
| 3:4 | 896x1200 | 1120 | 1792x2400 | 1120 | 3584x4800 | 2000 |
| 4:3 | 1200x896 | 1120 | 2400x1792 | 1120 | 4800x3584 | 2000 |
| 4:5 | 928x1152 | 1120 | 1856x2304 | 1120 | 3712x4608 | 2000 |
| 5:4 | 1152x928 | 1120 | 2304x1856 | 1120 | 4608x3712 | 2000 |
| 9:16 | 768x1376 | 1120 | 1536x2752 | 1120 | 3072x5504 | 2000 |
| 16:9 | 1376x768 | 1120 | 2752x1536 | 1120 | 5504x3072 | 2000 |
| 21:9 | 1584x672 | 1120 | 3168x1344 | 1120 | 6336x2688 | 2000 |
Error Codes
Common Error Codes
| Error Code | Error Name | Description |
|---|---|---|
| 401 | Unauthorized | API key is missing or invalid |
| 403 | Forbidden | Your API key doesn’t have permission to access this resource, or insufficient balance for the requested operation |
| 429 | Too Many Requests | You’ve exceeded your rate limit |
| 500 | Internal server error | An internal server error occurred |
| 503 | Content policy violation | Content blocked due to safety concerns (actual status code is 400) |
⌘I

