server: accept OpenAI video_url content type and data: video URIs (#27921)

The OpenAI chat completions API specifies content part type "video_url"
with a {"url": ...} object, and clients typically send data: URIs
(e.g. data:video/mp4;base64,...). The llama-server only accepted the
non-standard "input_video" type and rejected data: URIs for video
(accept_base64_uri=false), so any OpenAI-conformant client failed with
"unsupported content[].type" or "Invalid uri format".

- accept "video_url" as an alias of "input_video"
- read the media object from whichever key was used
- allow data: URIs for video (data:video/*), as already done for images
This commit is contained in:
calebrio02
2026-09-23 12:58:09 +02:00
committed by GitHub
parent bcbc936a87
commit 057494f93f
+4 -2
View File
@@ -1263,12 +1263,13 @@ json oaicompat_chat_params_parse(
p["text"] = get_media_marker();
p.erase("input_audio");
} else if (type == "input_video") {
} else if (type == "input_video" || type == "video_url") {
if (!opt.allow_video) {
throw std::runtime_error("video input is not supported - hint: if this is unexpected, you may need to provide the mmproj");
}
json input_video = json_value(p, "input_video", json::object());
// accept the OpenAI-style "video_url" key as an alias of "input_video"
json input_video = json_value(p, type, json::object());
std::string url = json_value(input_video, "data",
json_value(input_video, "url", std::string()));
handle_media(out_files, url, opt.media_path);
@@ -1276,6 +1277,7 @@ json oaicompat_chat_params_parse(
p["type"] = "media_marker";
p["text"] = get_media_marker();
p.erase("input_video");
p.erase("video_url");
} else if (type != "text") {
throw std::invalid_argument("unsupported content[].type");