Skip to content

feat: add video_url support for multimodal video content#417

Open
rafalzawadzki wants to merge 1 commit intoOpenRouterTeam:mainfrom
rafalzawadzki:fix/add-video-supported-urls
Open

feat: add video_url support for multimodal video content#417
rafalzawadzki wants to merge 1 commit intoOpenRouterTeam:mainfrom
rafalzawadzki:fix/add-video-supported-urls

Conversation

@rafalzawadzki
Copy link

@rafalzawadzki rafalzawadzki commented Feb 14, 2026

Summary

Adds support for passing video URLs through to OpenRouter's video_url format, enabling multimodal video analysis (e.g., YouTube URLs via Gemini through OpenRouter).

Problem

Without this change, the Vercel AI SDK downloads video URLs client-side (converting to base64) because video/* is not in the provider's supportedUrls. This breaks YouTube URL support since OpenRouter proxies to Google AI Studio, which natively handles YouTube URLs via video_url — but only if the URL is passed through as-is.

Changes

  1. Added video/* and audio/* to supportedUrls in both chat/index.ts and completion/index.ts — prevents the AI SDK from downloading video/audio URLs client-side
  2. Added video_url message format handler in convert-to-openrouter-chat-messages.ts — converts type: "file" with video/* mediaType to OpenRouter's { type: "video_url", video_url: { url } } format (docs)
  3. Added ChatCompletionContentPartVideo type in openrouter-chat-completions-input.ts

Video files (type: "file" with mediaType: "video/*") were falling through
to the generic file handler, which caused two issues:

1. The AI SDK would download video URLs client-side before sending them,
   because video/* was not in supportedUrls. This meant YouTube URLs
   (which aren't downloadable files) would fail entirely.

2. Video files were sent as { type: "file", file: { file_data } } instead
   of { type: "video_url", video_url: { url } }, which is the format
   documented at openrouter.ai/docs/guides/overview/multimodal/videos.

This commit:
- Adds video/* and audio/* to supportedUrls in both chat and completion
  models, so the AI SDK passes video/audio URLs through without downloading
- Adds a video-specific handler in convertToOpenRouterChatMessages that
  converts video file parts to the video_url format
- Adds ChatCompletionContentPartVideo type

Tested with YouTube URLs through Google AI Studio provider — both
generateText and generateObject work correctly with Gemini 2.5 Flash.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rafalzawadzki rafalzawadzki force-pushed the fix/add-video-supported-urls branch 2 times, most recently from 08afcb6 to 2830319 Compare February 23, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant