{"record":{"id":"512440a88c1d7ca6","repo":"BerriAI/litellm","slug":"error-msg-response-text","errorCode":null,"errorMessage":"{error_msg}: {response.text}","messagePattern":"\\{error_msg\\}: \\{response\\.text\\}","errorType":"http","errorClass":"AzureAIAgentsError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/agents/handler.py","lineNumber":303,"sourceCode":"\n        # Azure Foundry Agents uses Bearer token authentication\n        # The api_key here is expected to be an Azure AD token\n        if api_key:\n            headers[\"Authorization\"] = f\"Bearer {api_key}\"\n\n        api_version: Final = optional_params.get(\"api_version\", self.config.DEFAULT_API_VERSION)\n        agent_id: Final = self.config._get_agent_id(model, optional_params)\n        thread_id: Final = optional_params.get(\"thread_id\")\n        api_base = api_base.rstrip(\"/\")\n\n        verbose_logger.debug(\"Azure AI Agents completion - api_base: %s, agent_id: %s\", api_base, agent_id)\n\n        return headers, api_version, agent_id, thread_id, api_base\n\n    def _check_response(self, response: httpx.Response, expected_codes: list[int], error_msg: str):\n        \"\"\"Check response status and raise error if not expected.\"\"\"\n        if response.status_code not in expected_codes:\n            raise AzureAIAgentsError(\n                status_code=response.status_code,\n                message=f\"{error_msg}: {response.text}\",\n            )\n\n    # -------------------------------------------------------------------------\n    # Sync Completion\n    # -------------------------------------------------------------------------\n    def completion(\n        self,\n        model: str,\n        messages: list[dict[str, object]],\n        api_base: str,\n        api_key: str,\n        model_response: ModelResponse,\n        logging_obj: LiteLLMLoggingObj,\n        optional_params: dict,\n        litellm_params: dict,\n        timeout: float,","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/azure_ai/agents/handler.py#L285-L321","documentation":"Error \"{error_msg}: {response.text}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure_ai/agents/handler.py:303 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read error_msg and response body in the error; fix the request per the Azure AI Agents API error returned."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}