POST
/
v1
/
chat
/
completions
Chat Completions Vision (Non-Stream)
curl --request POST \
  --url https://api.example.com/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "stream": true,
  "max_tokens": 123,
  "temperature": 123,
  "detail": "<string>"
}
'
Create a model response that can understand and analyze images with non-streaming response.

Overview

The Vision API allows you to send images to the model and receive descriptions, analysis, or answers to questions about the image content. This endpoint returns the complete response at once without streaming.

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
ID of the model to use. Must be a vision-capable model like gpt-4-vision-preview, gpt-4o, or gpt-4o-mini.
messages
array
required
A list of messages with image content. Images can be provided via URL or base64.
stream
boolean
default:"false"
Set to false or omit for non-streaming responses.
max_tokens
integer
Maximum number of tokens to generate in the response.
temperature
number
default:"1"
Sampling temperature between 0 and 2.
detail
string
default:"auto"
Image detail level: low, high, or auto. Controls how the model processes the image.

Request Example

curl -X POST https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What is in this image?"},
          {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
        ]
      }
    ],
    "max_tokens": 1000
  }'

Response Example

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image shows a beautiful sunset over the ocean. The sky is painted with vibrant shades of orange, pink, and purple, reflecting off the calm water surface. In the foreground, there's a silhouette of a palm tree, adding a tropical feel to the scene."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1118,
    "completion_tokens": 65,
    "total_tokens": 1183
  }
}

Supported Image Formats

  • PNG
  • JPEG
  • GIF
  • WebP

Available Models

  • gpt-4-vision-preview
  • gpt-4o
  • gpt-4o-mini