fix: use provider_data API keys in list_provider_model_ids

Anthropic and Databricks providers were calling get_api_key() which only
checks config, not provider_data. Changed to use
_get_api_key_from_config_or_provider_data() so dynamic model listing works
with per-request API keys.
This commit is contained in:
Ashwin Bharambe 2025-10-29 11:34:06 -07:00
parent c0d51c89e6
commit 7293d438ef
2 changed files with 4 additions and 2 deletions

View file

@ -33,4 +33,5 @@ class AnthropicInferenceAdapter(OpenAIMixin):
return "https://api.anthropic.com/v1" return "https://api.anthropic.com/v1"
async def list_provider_model_ids(self) -> Iterable[str]: async def list_provider_model_ids(self) -> Iterable[str]:
return [m.id async for m in AsyncAnthropic(api_key=self.get_api_key()).models.list()] api_key = self._get_api_key_from_config_or_provider_data()
return [m.id async for m in AsyncAnthropic(api_key=api_key).models.list()]

View file

@ -33,10 +33,11 @@ class DatabricksInferenceAdapter(OpenAIMixin):
async def list_provider_model_ids(self) -> Iterable[str]: async def list_provider_model_ids(self) -> Iterable[str]:
# Filter out None values from endpoint names # Filter out None values from endpoint names
api_token = self._get_api_key_from_config_or_provider_data()
return [ return [
endpoint.name # type: ignore[misc] endpoint.name # type: ignore[misc]
for endpoint in WorkspaceClient( for endpoint in WorkspaceClient(
host=self.config.url, token=self.get_api_key() host=self.config.url, token=api_token
).serving_endpoints.list() # TODO: this is not async ).serving_endpoints.list() # TODO: this is not async
] ]