mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix: preserve pre-fetched Authorization header for vertex_ai partner models
- Skip _ensure_access_token if Authorization already in headers - Only overwrite Authorization if not already present and access_token exists Fixes #23572
This commit is contained in:
parent
095f5e8399
commit
09681c7d41
1 changed files with 12 additions and 6 deletions
|
|
@ -135,11 +135,15 @@ class VertexAIPartnerModels(VertexBase):
|
|||
try:
|
||||
vertex_httpx_logic = VertexLLM()
|
||||
|
||||
access_token, project_id = vertex_httpx_logic._ensure_access_token(
|
||||
credentials=vertex_credentials,
|
||||
project_id=vertex_project,
|
||||
custom_llm_provider="vertex_ai",
|
||||
)
|
||||
# Only fetch access token if Authorization header not already provided
|
||||
if headers is None or "Authorization" not in headers:
|
||||
access_token, project_id = vertex_httpx_logic._ensure_access_token(
|
||||
credentials=vertex_credentials,
|
||||
project_id=vertex_project,
|
||||
custom_llm_provider="vertex_ai",
|
||||
)
|
||||
else:
|
||||
access_token, project_id = None, None
|
||||
|
||||
openai_like_chat_completions = OpenAILikeChatHandler()
|
||||
codestral_fim_completions = CodestralTextCompletion()
|
||||
|
|
@ -198,7 +202,9 @@ class VertexAIPartnerModels(VertexBase):
|
|||
elif "claude" in model:
|
||||
if headers is None:
|
||||
headers = {}
|
||||
headers.update({"Authorization": "Bearer {}".format(access_token)})
|
||||
# Only set Authorization if not already present and we have an access_token
|
||||
if "Authorization" not in headers and access_token is not None:
|
||||
headers.update({"Authorization": "Bearer {}".format(access_token)})
|
||||
|
||||
optional_params.update(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue