/v1/chat/completions, or
analyze images and video by passing them alongside text in the same request.
The endpoint is fully compatible with the OpenAI Chat Completions API, so
existing OpenAI SDK code works unchanged.
Check the supported models page to see which models are available
via shared or dedicated endpoints, and which support text generation versus
image/video analysis.
The v1/chat/completions endpoint
The v1/chat/completions endpoint supports both single-turn and multi-turn
interactions. You provide a sequence of structured messages with roles
(system, user, assistant), and the model generates a response.
For example, within the v1/chat/completions request body, the "messages"
array might look similar to the following:
system
message can define overall model response behavior, user messages represent
instructions or prompts from the end-user, and assistant messages incorporate
past model responses into the context.
You can also include image or video inputs alongside text to work with
multimodal models.
Generate text
Generate text from a prompt or conversation history usingv1/chat/completions:
- Python
- curl
Send a chat completion request using the OpenAI Python SDK:
generate-text.py
Stream responses in real time
Setstream=True to receive tokens as they are generated instead of waiting
for the full response:
- Python
- curl
Set
stream=True and iterate over the response chunks as they arrive:stream-text.py
Analyze images
Send images to the model alongside text prompts to get descriptions, answers to questions, or extracted information from visual content.Pass image or video URLs
Within thev1/chat/completions request body, the "messages" array accepts
inline image or video URLs.
- Image input
- Video input
Use
image_url to pass an image:image_url and video_url also accept base64-encoded data URIs
(such as data:image/jpeg;base64,... or data:video/mp4;base64,...).
Describe an image
Send an image URL alongside a text question to get a description or analysis of the image:- Python
- curl
Include an
image_url content block alongside your text prompt:generate-image-description.py
Describe video content
Send a video URL alongside a text question to get a description or analysis of the video’s visual content.Describe a video
Include avideo_url content block in your request to analyze what happens in
a video:
- Python
- curl
Pass a video URL and a text question to get a natural-language description of
the video:
generate-video-description.py