SambaNova supports video input for select multimodal models on both SambaNova Cloud and SambaStack 1.2, allowing you to pass video files alongside text prompts. Learn how to query SambaNova video-capable models using either the SambaNova or OpenAI Python client.
Video input is currently supported on gemma-4-31B-it. This model does not support audio input.
Videos must meet the following requirements:
Maximum duration: 60 seconds
Frame rate: 2 fps
Maximum file size: 100 MB
Duration metadata: The video file must have readable duration metadata
Always use "type": "video_url" with a nested video_url object. Using "type": "video" is not supported and causes a validation error.
Make a query with a video
The video request follows the multimodal input format. Pass the video as a base64-encoded string or a URL using the video_url content type.
Step 1
Make a new Python file and copy the code below. Python (SambaNova)
Python (OpenAI)
from sambanova import SambaNova
import base64
client = SambaNova(
base_url = "your-sambanova-base-url" ,
api_key = "your-sambanova-api-key" ,
)
def encode_video ( video_path ):
with open (video_path, "rb" ) as video_file:
return base64.b64encode(video_file.read()).decode( "utf-8" )
video_path = "sample.mp4"
video_base64 = encode_video(video_path)
response = client.chat.completions.create(
model = "gemma-4-31B-it" ,
messages = [
{
"role" : "user" ,
"content" : [
{ "type" : "text" , "text" : "Describe what is happening in this video." },
{
"type" : "video_url" ,
"video_url" : { "url" : f "data:video/mp4;base64, { video_base64 } " },
},
],
}
],
)
print (response.choices[ 0 ].message.content)
from openai import OpenAI
import base64
client = OpenAI(
base_url = "your-sambanova-base-url" ,
api_key = "your-sambanova-api-key" ,
)
def encode_video ( video_path ):
with open (video_path, "rb" ) as video_file:
return base64.b64encode(video_file.read()).decode( "utf-8" )
video_path = "sample.mp4"
video_base64 = encode_video(video_path)
response = client.chat.completions.create(
model = "gemma-4-31B-it" ,
messages = [
{
"role" : "user" ,
"content" : [
{ "type" : "text" , "text" : "Describe what is happening in this video." },
{
"type" : "video_url" ,
"video_url" : { "url" : f "data:video/mp4;base64, { video_base64 } " },
},
],
}
],
)
print (response.choices[ 0 ].message.content)
Step 2
Use your SambaNova API key and base URL from the API keys and URLs page to replace "your-sambanova-api-key" and "your-sambanova-base-url".
Step 3
Replace "sample.mp4" with the path to your video file.
Step 4
Update the prompt text in the content array to match your use case.
Step 5
Run the Python file to receive the text output.
The video_url content block accepts either a base64-encoded video or a URL:
{
"type" : "video_url" ,
"video_url" : {
"url" : "data:video/mp4;base64,<base64-encoded-video>"
}
}
{
"type" : "video_url" ,
"video_url" : {
"url" : "https://example.com/sample.mp4"
}
}