mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
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:
parent
9edc1018fb
commit
519b979b23
2 changed files with 9 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue