mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
refactor(dashscope): consolidate api_key resolution to main.py
This commit is contained in:
parent
87d1208ae6
commit
ec05003337
1 changed files with 3 additions and 7 deletions
|
|
@ -72,15 +72,11 @@ class DashScopeEmbeddingConfig(BaseEmbeddingConfig):
|
|||
api_key: Optional[str] = None,
|
||||
api_base: Optional[str] = None,
|
||||
) -> dict:
|
||||
resolved_key = api_key or get_secret_str("DASHSCOPE_API_KEY")
|
||||
if not resolved_key:
|
||||
raise ValueError(
|
||||
"Missing API key for DashScope. Set DASHSCOPE_API_KEY environment "
|
||||
"variable or pass api_key parameter."
|
||||
)
|
||||
if api_key is None:
|
||||
raise ValueError("api_key is required for DashScope authentication")
|
||||
default_headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {resolved_key}",
|
||||
"Authorization": f"Bearer {api_key}",
|
||||
}
|
||||
return {**default_headers, **headers}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue