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

Supported inputs & outputs :

Inputs: Text Outputs: Text and image

Text-to-Image

The default output size for chat mode is 1:1 (1024x1024)
{
  "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.
modelstring✅ Yesgemini-2.5-flash-image-previewThe model to use for the request

Response

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "Here's your nano banana dish in a fancy restaurant with a Gemini theme! \n![image](data:image/png;base64,iVBORw0....)",
                "role": "assistant"
            }
        }
    ],
    "created": 1762163196,
    "id": "chatcmpl-20251103174627570914749cO7T1Yq5",
    "model": "gemini-2.5-flash-image-preview",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 1307,
        "completion_tokens_details": {
            "accepted_prediction_tokens": 0,
            "audio_tokens": 0,
            "reasoning_tokens": 0,
            "rejected_prediction_tokens": 0
        },
        "prompt_tokens": 16,
        "prompt_tokens_details": {
            "audio_tokens": 0,
            "cached_tokens": 0
        },
        "total_tokens": 1323
    }
}