POST
/
v1
/
chat
/
completions
Chat Completions Vision (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 streaming enabled.

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 supports streaming responses for real-time feedback.

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.
stream
boolean
required
Must be set to true for 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"}}
        ]
      }
    ],
    "stream": true,
    "max_tokens": 1000
  }'

Response Example (SSE Stream)

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"The image shows"},"finish_reason":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" a beautiful sunset"},"finish_reason":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Supported Image Formats

  • PNG
  • JPEG
  • GIF
  • WebP

Available Models

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