video_url content part, or upload a video through the Files API.
Explore the dedicated guides for video Q&A, moments and intervals, reference-image video search, and object tracking.
Ask about a video
Installperceptron>=0.4.0 and set PERCEPTRON_API_KEY. The video() helper accepts a URL, local file, or uploaded file reference.
Analyze video soundtracks
Videos are processed as frames only by default. Setvision_config.enable_audio_in_video: true when speech, sound effects, or other audio matters to your question. Run this after creating client above; this basketball sample contains an audio track:
video_url parts and uploaded video_file_id parts. When omitted or set to false, the soundtrack is not processed. It does not enable or disable standalone audio inputs. Preselected video_frames contain no soundtrack, so the flag has no effect on those frames.
A video with no audio stream, or no soundtrack overlapping the sampled video window, is processed as frames only. A video with an encoded silent audio track still consumes audio tokens when enable_audio_in_video is explicitly set to true. An audio decode failure or audio-token limit violation still returns an error; enabling sound does not silently discard those failures.
Audio uses approximately 750 encoder tokens per minute, plus timestamp tokens in the prompt. The per-item audio limit is 16,384 encoder tokens, roughly 21.8 minutes; video frames, other inputs, and the requested output also need to fit the shared context budget. Check usage.prompt_tokens_details.audio_tokens for the audio encoder contribution when returned. See Audio and tokenization for formats and budgeting.
Locate an event in time
Useannotation_format: "clip" when your application needs a moment or interval. Run this after the setup above:
Choose a video workflow
Send timestamped frames
Usevideo_frames when you have already selected frames from a video. Provide at least two frames with the same image dimensions, each with an image_url and a non-negative integer timestamp_ms. Keep frames in timestamp order; equal timestamps are allowed. URLs can be HTTP(S) URLs or supported image data URLs.
The SDK’s video_frames() helper accepts (image, timestamp_ms) pairs and encodes local frames for you. Save frames from 0 and 1.5 seconds of your clip as frame-000.png and frame-1500.png; change the filenames and timestamps to match your selected frames. Run this after creating client above:
video_frames group is one asset for asset_idx. Each supplied frame consumes one media unit, so this example uses one asset index and two of the request’s 256 media units. Sending those frames as separate image_url content parts would instead create two image assets. See multiple assets.
Timestamps are preserved, not automatically rebased: 1500 milliseconds corresponds to 1.5 seconds in annotations. If these frames came from an excerpt starting at 60 seconds and you supplied excerpt-relative timestamps 0 and 1500, add the 60-second offset when mapping results back to the source. If you supplied source-relative timestamps 60000 and 61500, the timeline is already 60 and 61.5 seconds; do not add the offset again. Keep this mapping with your media, and check finish_reason before using the answer.
Selected frames provide sparse observations; they do not establish what happened between them. See recover a gap with new model observations when you need more observations in an uncertain tracking interval.