Skip to main content
POST
/
v1
/
chat
/
completions
gemini-2.0-flash-exp (Image To Text)
curl --request POST \
  --url https://api.example.com/v1/chat/completions

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/v1/chat/completions' \
--header 'Authorization: GPTPROTO_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "gemini-2.0-flash-exp",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What is shown in this PNG image?"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://tos.gptproto.com/resource/cat.png"
          }
        }
      ]
    }
  ]
}'

Response Example

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "Based on the image provided, here is a description of what is shown:\n\n**Main Subject:**\n*   **The Cat:** A fluffy, long-haired orange tabby cat is the central focus. It is sitting upright on a wooden windowsill, looking calmly toward the viewer with bright green eyes. Its tail is curled neatly around its paws.\n\n**Setting and Atmosphere:**\n*   **The Window:** The cat is perched on the sill of a large window with a wooden frame. Through the glass, you can see a blurred outdoor scene with a large tree trunk and greenery, suggesting a garden or park.\n*   **Lighting:** Warm, natural sunlight is streaming in from the left, illuminating the cat's fur and creating a soft, hazy atmosphere with visible dust motes floating in the air. The mood is serene and domestic.\n\n**Surrounding Objects:**\n*   **Book:** To the left of the cat on the windowsill lies a thick, closed hardcover book.\n*   **Tea:** In the foreground on the right, resting on a small round side table, is a teacup and saucer. Steam is rising from the cup, indicating a hot beverage like tea or coffee.\n*   **Furniture:** To the right of the window, there is a tall bookshelf filled with books. partially visible is a leather armchair with a chunky, cream-colored knit blanket draped over it, adding to the cozy aesthetic.\n\nOverall, the image conveys a sense of \"hygge\"—a feeling of cozy contentment and well-being.",
                "role": "assistant"
            }
        }
    ],
    "created": 1766411359,
    "id": "chatcmpl-***",
    "model": "gemini-2.0-flash-exp",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 1258,
        "completion_tokens_details": {
            "accepted_prediction_tokens": 0,
            "audio_tokens": 0,
            "reasoning_tokens": 943,
            "rejected_prediction_tokens": 0
        },
        "prompt_tokens": 1097,
        "prompt_tokens_details": {
            "audio_tokens": 0,
            "cached_tokens": 0
        },
        "total_tokens": 2355
    }
}

Parameters

Core Parameters

ParameterTypeRequiredDefaultRangeDescription
modelstring✅ Yes--Model ID used to generate the response, like gpt-4o or o3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.
messagesarray✅ Yes--A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.
>messages.rolestring✅ Yes-developer
user
system
The role of the messages author.
>messages.namestring❌ No--An optional name for the participant. Provides the model information to differentiate between participants of the same role.
>messages.contentstring / array✅ Yes--The contents of the developer message.
>>messages.content.typestring✅ Yes-text
image_url
The type of the content part
>>messages.content.textstring❌ No--The text content
>>messages.content.image_urlobject❌ No--The image URL content
>>messages.content.image_url.urlstring❌ No--The URL of the image

Advanced Parameters

ParameterTypeRequiredDefaultRangeDescription
max_completion_tokensinteger / null❌ No--An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
streamboolean❌ Nofalsetrue
false
Whether to stream the response back incrementally. Defaults to false.

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)