BerriAI/litellm · error · ValueError
api_key is required
Error message
api_key is required
What it means
Azure AI Search vector-store operations authenticate with an api-key header. get_auth_credentials reads litellm_params['api_key'] and raises immediately if absent — there is no env-var fallback in this path, unlike the chat/rerank configs.
Source
Thrown at litellm/llms/azure_ai/vector_stores/transformation.py:71
``/analyze`` inside the batch-write path); writes are classified before
reads, so such a path demands the write grant rather than being
shadowed into a read.
"""
return {
"read": [
("GET", "/indexes/"),
("POST", "/docs/search"),
("POST", "/docs/suggest"),
("POST", "/docs/autocomplete"),
("POST", "/analyze"),
],
"write": [("POST", "/docs/index")],
}
def get_auth_credentials(self, litellm_params: dict) -> BaseVectorStoreAuthCredentials:
api_key: Final = litellm_params.get("api_key")
if api_key is None:
raise ValueError("api_key is required")
return {
"headers": {
"api-key": api_key,
}
}
def validate_environment(self, headers: dict, litellm_params: GenericLiteLLMParams | None) -> dict:
basic_headers: Final = self._base_validate_azure_environment(headers, litellm_params)
basic_headers.update({"Content-Type": "application/json"})
return basic_headers
def get_complete_url(
self,
api_base: str | None,
litellm_params: dict,
) -> str:
"""View on GitHub (pinned to 6c2dcb801b)
Solutions
- Add api_key to the vector store's litellm_params: litellm_params={'api_key': os.environ['AZURE_SEARCH_API_KEY'], 'azure_search_service_name': 'my-service'}
- In proxy config, set vector_stores[i].litellm_params.api_key (supports os.environ/ references)
- Verify with a quick print that the litellm_params dict actually contains a non-None api_key before the call
Example fix
# before
vs_config = {'provider': 'azure_ai_search', 'litellm_params': {'azure_search_service_name': 'my-service'}}
# after
vs_config = {'provider': 'azure_ai_search', 'litellm_params': {'api_key': os.environ['AZURE_SEARCH_ADMIN_KEY'], 'azure_search_service_name': 'my-service'}} Defensive patterns
Strategy: validation
Validate before calling
if not litellm_params.get('api_key'):
raise ValueError('azure_ai_search vector store requires litellm_params["api_key"]') Prevention
- Validate the full vector-store litellm_params dict in a config-check function at startup
- Keep Azure Search admin keys in a secret manager and inject them at config build time
When it happens
Trigger: Creating or using an azure_ai_search vector store (e.g. litellm.vector_store.create / search with provider azure_ai_search) where the vector store's litellm_params dict has no api_key entry.
Common situations: Configuring the vector store in proxy config.yaml with only azure_search_service_name set; migrating from a provider that pulled keys from env automatically; passing the key under a different name like azure_search_api_key.
Related errors
- Azure AI Search service name is required. Provide it via lit
- embedding_model is required in litellm_params for Azure AI S
- embedding_config is required in litellm_params for Azure AI
- api_key is required for Azure AI Speech transcription.
- AZURE_CLIENT_ID and AZURE_TENANT_ID must be set
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/e9391d3bc4fc5e4c.
Report an issue: GitHub.