BerriAI/litellm · error · AzureAIAgentsError

{error_msg}: {response.text}

Error message

{error_msg}: {response.text}

What it means

Error "{error_msg}: {response.text}" thrown in BerriAI/litellm.

Solutions

  1. Read error_msg and response body in the error; fix the request per the Azure AI Agents API error returned.

When it happens

Trigger: Thrown at litellm/llms/azure_ai/agents/handler.py:303 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/512440a88c1d7ca6. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure_ai/agents/handler.py:303

        # Azure Foundry Agents uses Bearer token authentication
        # The api_key here is expected to be an Azure AD token
        if api_key:
            headers["Authorization"] = f"Bearer {api_key}"

        api_version: Final = optional_params.get("api_version", self.config.DEFAULT_API_VERSION)
        agent_id: Final = self.config._get_agent_id(model, optional_params)
        thread_id: Final = optional_params.get("thread_id")
        api_base = api_base.rstrip("/")

        verbose_logger.debug("Azure AI Agents completion - api_base: %s, agent_id: %s", api_base, agent_id)

        return headers, api_version, agent_id, thread_id, api_base

    def _check_response(self, response: httpx.Response, expected_codes: list[int], error_msg: str):
        """Check response status and raise error if not expected."""
        if response.status_code not in expected_codes:
            raise AzureAIAgentsError(
                status_code=response.status_code,
                message=f"{error_msg}: {response.text}",
            )

    # -------------------------------------------------------------------------
    # Sync Completion
    # -------------------------------------------------------------------------
    def completion(
        self,
        model: str,
        messages: list[dict[str, object]],
        api_base: str,
        api_key: str,
        model_response: ModelResponse,
        logging_obj: LiteLLMLoggingObj,
        optional_params: dict,
        litellm_params: dict,
        timeout: float,

View on GitHub (pinned to 77b7c6c40c)