Skip to navigation

Video Inputs

Send a video as a video_url part in a chat message. The url can be a link or a base64 data URL. Use it to summarise videos, find objects and actions, describe scenes or review footage.

The samples use the OpenAI SDK set up as in the Quickstart.

From a URL

response = client.chat.completions.create(
model="<model with video input>",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Summarise this video in five bullet points."},
{"type": "video_url", "video_url": {"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}},
],
}],
)
print(response.choices[0].message.content)

Which links work depends on the model’s host. Some take only YouTube links, some take none. If a link doesn’t work, send the video as base64.

From a local file

Python
import base64
with open("clip.mp4", "rb") as f:
video = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="<model with video input>",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "What happens in this clip?"},
{"type": "video_url", "video_url": {"url": f"data:video/mp4;base64,{video}"}},
],
}],
)

Formats

  • video/mp4
  • video/mpeg
  • video/mov
  • video/webm

Tips

  • Keep files small. Compress, cut to the part you need, and lower the resolution: 720p is enough for most analysis, 480p for basic scene understanding.
  • Split long videos. Each model has a maximum length; send long footage in parts and focus on the moments that matter.
  • Ask a specific question about what to look for.

Troubleshooting

  • Refused with 400: the model doesn’t take video. Pick a model that does.
  • The link is ignored or fails: the host doesn’t accept that kind of link. Send base64 instead.
  • Request too large: compress the video, lower its resolution or frame rate, or cut it shorter.

Billing

The model turns the video into input tokens by its length and resolution, at its input price. Video takes many tokens per second, so check usage.prompt_tokens on a short clip first. A model that doesn’t take video refuses the request with a 400 before anything is held.