mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-23 03:42:26 +00:00
feat: Add clear error message when API key is missing
Improve user experience by providing specific guidance when no API key is available, showing both provider data header and config options with the correct field name for each provider. Also adds comprehensive test coverage for API key resolution scenarios.
This commit is contained in:
parent
5c33bc1353
commit
cef616732c
2 changed files with 118 additions and 0 deletions
|
|
@ -254,6 +254,12 @@ class LiteLLMOpenAIMixin(
|
|||
api_key = getattr(provider_data, key_field)
|
||||
else:
|
||||
api_key = self.api_key_from_config
|
||||
if not api_key:
|
||||
raise ValueError(
|
||||
"API key is not set. Please provide a valid API key in the "
|
||||
"provider data header, e.g. x-llamastack-provider-data: "
|
||||
f'{{"{key_field}": "<API_KEY>"}}, or in the provider config.'
|
||||
)
|
||||
return api_key
|
||||
|
||||
async def embeddings(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue