Skip to main content
POST
/
v1
/
chat
/
completions
gpt-4.1 (image analysis)
curl --request POST \
  --url https://api.example.com/v1/chat/completions
OpenAI’s official format(chat) for the image analysis API.
curl -X POST "https://gptproto.com/v1/chat/completions" \
  -H "Authorization: sk-*****" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-4.1",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What is in this image?"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
          }
        }
      ]
    }
  ]
}'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "gpt-4.1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image shows a wooden boardwalk path extending through a lush green grassland. The boardwalk appears to lead toward a distant tree line under a bright blue sky with some clouds. The grass on either side of the boardwalk is vibrant green, suggesting it might be spring or summer. The scene has a peaceful, natural atmosphere with good visibility and sunny weather conditions."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1250,
    "completion_tokens": 89,
    "total_tokens": 1339
  }
}

Request Body

ParameterTypeRequiredDefaultDescription
modelstring✅ Yesgpt-4.1The model to use for the request
messagesarray✅ Yes-Array of message objects for the conversation
streamboolean❌ NofalseWhether to stream the response

Messages Array Structure

Each message object in the messages array should have the following structure:
FieldTypeRequiredDescription
rolestring✅ YesThe role of the message. Can be: user, assistant, or system
contentarray✅ YesArray of content objects (can include text and images)

Content Array Items

The content array can contain multiple items of different types:

Text Content

FieldTypeRequiredExampleDescription
typestring✅ Yes"text"Must be text for text content
textstring✅ Yes"What is in this image?"The text prompt or question

Image URL Content

FieldTypeRequiredExampleDescription
typestring✅ Yes"image_url"Must be image_url for image content
image_urlobject✅ YesSee belowObject containing the image URL
image_url.urlstring✅ Yes"https://example.com/image.jpg"The URL of the image to analyze