{"record":{"id":"fd23ae887b59f249","repo":"microsoft/autogen","slug":"if-credential-is-a-dict-it-must-contain-an-api-k","errorCode":null,"errorMessage":"If credential is a dict, it must contain an 'api_key' key","messagePattern":"If credential is a dict, it must contain an 'api_key' key","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":376,"sourceCode":"    ) -> Union[AzureKeyCredential, AsyncTokenCredential]:\n        \"\"\"Process credential to ensure it's the correct type for async SearchClient.\n\n        Converts dictionary credentials with 'api_key' to AzureKeyCredential objects.\n\n        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","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L358-L394","documentation":"Error \"If credential is a dict, it must contain an 'api_key' key\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:376 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include an api_key entry in the credential dict"],"exampleFix":"credential={'api_key': '<key>'}","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"}