Image, Audio, and Video Input
NIM LLM and VLM can serve multimodal models that accept image, audio, or video input through the vLLM backend. Use OpenAI-compatible Chat Completions requests with a mixed content array that contains text and media items.
This guide applies to models that support the media type you send. A text-only model cannot process image, audio, or video input. For model-specific limitations, refer to the model card and the Support Matrix for NIMs.
Prerequisites
Before you send image, audio, or video input, make sure you have the following:
- A NIM LLM and VLM container with the vLLM backend.
- A model that supports image input, audio input, or video input (or some combination).
- A running NIM server and the served model name from
/v1/models. - Media URLs that are reachable from the NIM container.
- The Python package for the examples you run:
openaifor the OpenAI Python SDK examples orlangchain-openaifor the LangChain examples.
Send an Image Request
Send image input with a chat message content array that combines the prompt text with either a remote image URL or inline image bytes.
Use an External URL
Use an image_url item inside the chat message content array.
cURL
OpenAI Python SDK
LangChain
Send Inline Image Data
To avoid downloading an image from a URL at request time, use Python’s base64
module and pathlib.Path to encode the image bytes.
Pass the encoded bytes inline by setting image_url.url to a data URL such as
data:image/jpeg;base64,<base64-data>. Match the MIME type to the file, such as
image/png for a PNG file.
Send an Audio Request
Send audio input with a chat message content array that combines the prompt text with either a remote audio URL or inline audio bytes.
Use an External URL
Audio input uses a vLLM-specific audio_url extension. Use an audio_url
item inside the chat message content array.
cURL
OpenAI Python SDK
LangChain
Send Inline Audio Data
To avoid downloading an audio file from a URL at request time, use Python’s
base64 module and pathlib.Path to encode the audio bytes.
Pass the encoded bytes inline by setting audio_url.url to a data URL such as
data:audio/wav;base64,<base64-data>. Match the MIME type to the file, such as
audio/mpeg for an MP3 file or audio/flac for a FLAC file.
Send a Video Request
Send video input with a chat message content array that combines the prompt text with either a remote video URL or inline video bytes.
Use an External URL
Video input uses a vLLM-specific video_url extension. Use a video_url item
inside the chat message content array.
cURL
OpenAI Python SDK
LangChain
Send Inline Video Data
To avoid downloading a video from a URL at request time, use Python’s base64
module and pathlib.Path to encode the video bytes.
Pass the encoded bytes inline by setting video_url.url to
data:video/mp4;base64,<base64-data>.