microsoft/autogen · error · TypeError

Credential must be AzureKeyCredential, AsyncTokenCredential,

Error message

Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict

What it means

Error "Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict" thrown in microsoft/autogen.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:381

        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

        try:
            self._client = SearchClient(
                endpoint=self.search_config.endpoint,
                index_name=self.search_config.index_name,
                credential=self.search_config.credential,

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Use AzureKeyCredential, AsyncTokenCredential, or a dict with api_key

Example fix

Pass AzureKeyCredential('<key>') as credential

When it happens

Trigger: Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:381 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/7e421d71ba2b0479. Report an issue: GitHub.