Support checking provider-specific /models endpoints for available models based on key (#7538)

* test(test_utils.py): initial test for valid models

Addresses https://github.com/BerriAI/litellm/issues/7525

* fix: test

* feat(fireworks_ai/transformation.py): support retrieving valid models from fireworks ai endpoint

* refactor(fireworks_ai/): support checking model info on `/v1/models` route

* docs(set_keys.md): update docs to clarify check llm provider api usage

* fix(watsonx/common_utils.py): support 'WATSONX_ZENAPIKEY' for iam auth

* fix(watsonx): read in watsonx token from env var

* fix: fix linting errors

* fix(utils.py): fix provider config check

* style: cleanup unused imports
This commit is contained in:
Krish Dholakia 2025-01-03 19:29:59 -08:00 committed by GitHub
parent cac06a32b8
commit f770dd0c95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 350 additions and 42 deletions

View file

@ -175,7 +175,12 @@ class IBMWatsonXMixin:
if "Authorization" in headers:
return {**default_headers, **headers}
token = cast(Optional[str], optional_params.get("token"))
token = cast(
Optional[str],
optional_params.get("token")
or get_secret_str("WATSONX_ZENAPIKEY")
or get_secret_str("WATSONX_TOKEN"),
)
if token:
headers["Authorization"] = f"Bearer {token}"
else:
@ -245,6 +250,7 @@ class IBMWatsonXMixin:
)
token: Optional[str] = None
if wx_credentials is not None:
api_base = wx_credentials.get("url", api_base)
api_key = wx_credentials.get(