fix(vllm): support bearer auth for model discovery

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
jesus 2026-09-06 20:15:07 +00:00
parent 9edc1018fb
commit 519b979b23
2 changed files with 9 additions and 2 deletions

View file

@ -41,6 +41,7 @@ class VLLMModelInfo(BaseLLMModelInfo):
) -> dict:
if api_key is not None:
headers["x-api-key"] = api_key
headers["Authorization"] = f"Bearer {api_key}"
return headers
@staticmethod
@ -66,7 +67,10 @@ class VLLMModelInfo(BaseLLMModelInfo):
response: Final = (
litellm.module_level_client.get(
url=url,
headers={"x-api-key": api_key}, # mutable-ok: optional authentication header
headers={ # mutable-ok: optional authentication headers
"x-api-key": api_key,
"Authorization": f"Bearer {api_key}",
},
)
if api_key is not None
else litellm.module_level_client.get(url=url)

View file

@ -490,7 +490,10 @@ def test_get_known_models_from_wildcard_hosted_vllm_forwards_api_key():
litellm.check_provider_endpoint = original_check_provider_endpoint # test-quality-ok: restore test global
assert result == ["hosted_vllm/qwen2.5"]
assert mock_get.call_args.kwargs["headers"] == {"x-api-key": "test-key"}
assert mock_get.call_args.kwargs["headers"] == {
"x-api-key": "test-key",
"Authorization": "Bearer test-key",
}
def test_get_known_models_from_wildcard_unknown_provider_returns_empty():