Skip to main content
POST
/
v1
/
chat
/
completions
gemini-2.5-flash-image-preview (image edit)
curl --request POST \
  --url https://api.example.com/v1/chat/completions
Gemini’s openai format for the image edit API.

Supported inputs & outputs :

Inputs: Text and Images Outputs: Text and image
curl -X POST "https://gptproto.com/v1/chat/completions" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "messages": [
    {
      "role": "user",
      "content": "Two people standing together",
      "experimental_attachments": [
        {
          "contentType": "image/png",
          "url": "https://mgszhhytxjyitifbalro.supabase.co/storage/v1/object/public/chat-attachments/uploads/guakmauqtr.png"
        },
        {
          "contentType": "image/jpeg",
          "url": "https://mgszhhytxjyitifbalro.supabase.co/storage/v1/object/public/chat-attachments/uploads/3ox9ikxbcxc.jpeg"
        }
      ],
  	  "model": "gemini-2.5-flash-image-preview"
    }
  ]
}'
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}

Parameters

ParameterTypeRequiredDefaultDescription
messagesarray✅ Yes-Array of message objects for the conversation role of user.
contentstring✅ Yes-The prompt for the generation.
experimental_attachmentsarray✅ Yes-Supported MIME types:image/png, image/jpeg, image/webp
urlstring✅ Yes-image url.
modelstring✅ Yesgemini-2.5-flash-image-preview

Image Edit

The default output size for chat mode is 1:1 (1024x1024)

Response

{
  "candidates": [
      {
          "content": {
              "role": "model",
              "parts": [
                  {
                      "inlineData": {
                          "mimeType": "image/png",
                          "data": "base64"
                      }
                  }
              ]
          },
          "finishReason": "STOP"
      }
  ],
  "usageMetadata": {
      "promptTokenCount": 1302,
      "candidatesTokenCount": 1290,
      "totalTokenCount": 2592,
      "thoughtsTokenCount": 0,
      "promptTokensDetails": [
          {
              "modality": "IMAGE",
              "tokenCount": 1290
          },
          {
              "modality": "TEXT",
              "tokenCount": 12
          }
      ]
  },
  "modelVersion": "gemini-2.5-flash-image-preview"
}