From 519b979b23b23f428950ed98a0c97a97ee5d3ba9 Mon Sep 17 00:00:00 2001 From: jesus Date: Sun, 6 Sep 2026 20:15:07 +0000 Subject: [PATCH] fix(vllm): support bearer auth for model discovery Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/vllm/common_utils.py | 6 +++++- tests/test_litellm/proxy/auth/test_model_checks.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/litellm/llms/vllm/common_utils.py b/litellm/llms/vllm/common_utils.py index 106aae29aab..f1ad1b0ce11 100644 --- a/litellm/llms/vllm/common_utils.py +++ b/litellm/llms/vllm/common_utils.py @@ -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) diff --git a/tests/test_litellm/proxy/auth/test_model_checks.py b/tests/test_litellm/proxy/auth/test_model_checks.py index 021d6a7f056..83e6e46ea1a 100644 --- a/tests/test_litellm/proxy/auth/test_model_checks.py +++ b/tests/test_litellm/proxy/auth/test_model_checks.py @@ -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():