microsoft/autogen · error · ValueError
If credential is a dict, it must contain an 'api_key' key
Error message
If credential is a dict, it must contain an 'api_key' key
What it means
Error "If credential is a dict, it must contain an 'api_key' key" thrown in microsoft/autogen.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:376
) -> Union[AzureKeyCredential, AsyncTokenCredential]:
"""Process credential to ensure it's the correct type for async SearchClient.
Converts dictionary credentials with 'api_key' to AzureKeyCredential objects.
Args:
credential: The credential in either object or dictionary form
Returns:
A properly formatted credential object
Raises:
ValueError: If the credential dictionary doesn't contain an 'api_key'
TypeError: If the credential is not of a supported type
"""
if isinstance(credential, dict):
if "api_key" in credential:
return AzureKeyCredential(credential["api_key"])
raise ValueError("If credential is a dict, it must contain an 'api_key' key")
if isinstance(credential, (AzureKeyCredential, AsyncTokenCredential)):
return credential
raise TypeError("Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict")
async def _get_client(self) -> SearchClient:
"""Get the search client for the configured index.
Returns:
SearchClient: Initialized search client
Raises:
ValueError: If index doesn't exist or authentication fails
"""
if self._client is not None:
return self._client
View on GitHub (pinned to 027ecf0a37)
Solutions
- Include an api_key entry in the credential dict
Example fix
credential={'api_key': '<key>'} When it happens
Trigger: Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:376 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/fd23ae887b59f249.
Report an issue: GitHub.