Skip to content

vllm.multimodal.media.connector

Classes:

  • MediaConnector –

    Configuration values can be user-provided either by --media-io-kwargs or

Functions:

MediaConnector

Configuration values can be user-provided either by --media-io-kwargs or by the runtime API field "media_io_kwargs". Ensure proper validation and error handling.

Methods:

__init__(media_io_kwargs=None, connection=global_http_connection, *, allowed_local_media_path='', allowed_media_domains=None, decoded_budget=None, download_budget=None)

media_io_kwargs: Additional args passed to process media inputs, keyed by modalities. For example, to set num_frames for video, set --media-io-kwargs '{"video":{"num_frames":40}}' connection: HTTP connection client to download media contents. allowed_local_media_path: A local directory to load media files from. allowed_media_domains: If set, only media URLs that belong to this domain can be used for multi-modal inputs.

_get_cached_bytes(url)

Return cached bytes for a URL, or None if not cached/expired.

_maybe_evict(exclude=None)

Evict expired entries first, then LRU until under size limit.

_put_cached_bytes(url, data)

Store downloaded bytes and evict if over budget.

fetch_audio(audio_url)

Load audio from a URL.

fetch_audio_async(audio_url) async

Asynchronously fetch audio from a URL.

fetch_audio_embedding(data)

Load audio embedding from a URL.

fetch_audio_embedding_async(data) async

Asynchronously load audio embedding from a URL.

fetch_image(image_url, *, image_mode='RGB')

Load a PIL image from an HTTP or base64 data URL.

By default, the image is converted into RGB format. Set media_io_kwargs={"image": {"image_mode": None}} to keep the original image mode (e.g. preserving the alpha channel).

fetch_image_async(image_url, *, image_mode='RGB') async

Asynchronously load a PIL image from an HTTP or base64 data URL.

By default, the image is converted into RGB format. Set media_io_kwargs={"image": {"image_mode": None}} to keep the original image mode (e.g. preserving the alpha channel).

fetch_image_embedding(data)

Load image embedding from a URL.

fetch_image_embedding_async(data) async

Asynchronously load image embedding from a URL.

fetch_video(video_url, *, image_mode='RGB', video_processor=None, video_io_defaults=None)

Load video from an HTTP or base64 data URL.

fetch_video_async(video_url, *, image_mode='RGB', video_processor=None, video_io_defaults=None) async

Asynchronously load video from an HTTP or base64 data URL.

By default, the image is converted into RGB format. Set media_io_kwargs={"image": {"image_mode": None}} to keep the original image mode (e.g. preserving the alpha channel).

fetch_video_embedding(data)

Load video embedding from a URL.

fetch_video_embedding_async(data) async

Asynchronously load video embedding from a URL.

_wrap_media_fetch_error(url, exc, *, request_field='image_url')

Convert media fetch exceptions to VLLMUnprocessableEntityError.

Invalid media URLs (4xx responses except 408/429 and malformed URLs) and exceeded media fetch deadlines produce a 422 Unprocessable Entity error.

Transient errors (5xx, 408, 429, DNS failures, connection errors, socket timeouts) are returned as-is to allow retry logic to handle them appropriately.

Returns:

merge_media_io_kwargs(defaults, overrides)

Merge config-level and per-request media_io_kwargs per modality.

Each modality key is merged using the corresponding MediaIO subclass's merge_kwargs, which may apply modality-specific logic (e.g. VideoMediaIO clears cross-dependent fps/num_frames fields).