{"record":{"id":"7e421d71ba2b0479","repo":"microsoft/autogen","slug":"credential-must-be-azurekeycredential-asynctokenc","errorCode":null,"errorMessage":"Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict","messagePattern":"Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":381,"sourceCode":"        Args:\n            credential: The credential in either object or dictionary form\n\n        Returns:\n            A properly formatted credential object\n\n        Raises:\n            ValueError: If the credential dictionary doesn't contain an 'api_key'\n            TypeError: If the credential is not of a supported type\n        \"\"\"\n        if isinstance(credential, dict):\n            if \"api_key\" in credential:\n                return AzureKeyCredential(credential[\"api_key\"])\n            raise ValueError(\"If credential is a dict, it must contain an 'api_key' key\")\n\n        if isinstance(credential, (AzureKeyCredential, AsyncTokenCredential)):\n            return credential\n\n        raise TypeError(\"Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict\")\n\n    async def _get_client(self) -> SearchClient:\n        \"\"\"Get the search client for the configured index.\n\n        Returns:\n            SearchClient: Initialized search client\n\n        Raises:\n            ValueError: If index doesn't exist or authentication fails\n        \"\"\"\n        if self._client is not None:\n            return self._client\n\n        try:\n            self._client = SearchClient(\n                endpoint=self.search_config.endpoint,\n                index_name=self.search_config.index_name,\n                credential=self.search_config.credential,","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L363-L399","documentation":"Error \"Credential must be AzureKeyCredential, AsyncTokenCredential, or a valid dict\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:381 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use AzureKeyCredential, AsyncTokenCredential, or a dict with api_key"],"exampleFix":"Pass AzureKeyCredential('<key>') as credential","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}