Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/pass_through_endpoints/common_utils.py: 100%
7 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
1from typing import Final
3from fastapi import Request
6def get_litellm_virtual_key(request: Request) -> str:
7 """
8 Extract and format API key from request headers.
9 Prioritizes x-litellm-api-key over Authorization header.
12 Vertex JS SDK uses `Authorization` header, we use `x-litellm-api-key` to pass litellm virtual key
14 """
15 litellm_api_key: Final = request.headers.get("x-litellm-api-key")
16 if litellm_api_key:
17 return f"Bearer {litellm_api_key}"
18 return request.headers.get("Authorization", "")