mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(anthropic.py): fix pr for anthropic headers
This commit is contained in:
parent
1be4f7d2d1
commit
1ec5083542
1 changed files with 4 additions and 2 deletions
|
|
@ -78,7 +78,7 @@ class AnthropicConfig:
|
|||
|
||||
|
||||
# makes headers for API call
|
||||
def validate_environment(api_key):
|
||||
def validate_environment(api_key, user_headers):
|
||||
if api_key is None:
|
||||
raise ValueError(
|
||||
"Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params"
|
||||
|
|
@ -89,6 +89,8 @@ def validate_environment(api_key):
|
|||
"content-type": "application/json",
|
||||
"x-api-key": api_key,
|
||||
}
|
||||
if user_headers is not None and isinstance(user_headers, dict):
|
||||
headers = {**headers, **user_headers}
|
||||
return headers
|
||||
|
||||
|
||||
|
|
@ -107,7 +109,7 @@ def completion(
|
|||
logger_fn=None,
|
||||
headers={},
|
||||
):
|
||||
headers = { **validate_environment(api_key), **headers }
|
||||
headers = validate_environment(api_key, headers)
|
||||
if model in custom_prompt_dict:
|
||||
# check if the model has a registered custom prompt
|
||||
model_prompt_details = custom_prompt_dict[model]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue