BerriAI/litellm · error · ValueError

Prepared request body is empty

Error message

Prepared request body is empty

What it means

Post-preparation sentinel guard: after asyncify(self._prepare_request) builds the request, the resulting prepared_request.body is empty, meaning no JSON payload was produced for the SageMaker call, so the handler aborts before sending.

Source

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

            litellm_params=litellm_params,
            headers=headers,
        )
        asyncified_prepare_request: Final = asyncify(self._prepare_request)
        prepared_request_args: Final = {
            "model": model,
            "data": data,
            "optional_params": optional_params,
            "litellm_params": litellm_params,
            "credentials": credentials,
            "aws_region_name": aws_region_name,
            "messages": messages,
        }
        prepared_request: Final = await asyncified_prepare_request(**prepared_request_args)
        if model_id is not None:  # Fixes https://github.com/BerriAI/litellm/issues/8889
            prepared_request.headers.update({"X-Amzn-SageMaker-Inference-Component": model_id})

        if not prepared_request.body:
            raise ValueError("Prepared request body is empty")

        stream_logging_obj: Final[LiteLLMLoggingObj] = logging_obj
        completion_stream: Final = await self.make_async_call(
            api_base=prepared_request.url,
            headers=prepared_request.headers,
            data=cast(str, prepared_request.body),
            logging_obj=stream_logging_obj,
        )
        streaming_response: Final = CustomStreamWrapper(
            completion_stream=completion_stream,
            model=model,
            custom_llm_provider="sagemaker",
            logging_obj=stream_logging_obj,
        )

        # LOGGING
        logging_obj.post_call(
            input=[],

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Ensure the request includes a non-empty prompt/messages so the prepared body is not empty.
  2. Check input transformation for the SageMaker model type.

Example fix

# verify messages/prompt is passed and non-empty.
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when the prepared SageMaker completion request body is empty.

Common situations: See trigger scenarios.


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