BerriAI/litellm · error · SagemakerError

{str(sync_response.read())}

Error message

{str(sync_response.read())}

What it means

Streaming sync call guard: the POST to the SageMaker endpoint returned a status other than 200, so SagemakerError is raised with the status code and the fully-read response body before stream decoding begins.

Source

Thrown at litellm/llms/sagemaker/completion/handler.py:346

    def make_sync_call(
        self,
        api_base: str,
        headers: dict,
        data: str,
        logging_obj,
        client=None,
    ):
        if client is None:
            client = _get_httpx_client()
        sync_response: Final = client.post(
            api_base,
            headers=headers,
            data=data,
            stream=True,
        )

        if sync_response.status_code != 200:
            raise SagemakerError(status_code=sync_response.status_code, message=str(sync_response.read()))

        decoder: Final = AWSEventStreamDecoder(model="")
        return decoder.iter_bytes(sync_response.iter_bytes())

    async def make_async_call(
        self,
        api_base: str,
        headers: dict,
        data: str,
        logging_obj,
        client=None,
    ):
        try:
            if client is None:
                client = get_async_httpx_client(
                    llm_provider=litellm.LlmProviders.SAGEMAKER
                )  # Create a new client if none provided
            response: Final = await client.post(

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Inspect the raw streamed response content for the error detail.
  2. Verify the endpoint supports streaming and the payload format.

Example fix

# print the raw response bytes to see what the endpoint returned.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Triggered when reading the SageMaker completion streaming response body fails or yields an error payload.

Common situations: See trigger scenarios.


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