BerriAI/litellm · error · ValueError

Empty request body. For file uploads, use multipart/form-dat

Error message

Empty request body. For file uploads, use multipart/form-data content type with a file field. When using curl with --form/-F, do NOT set the Content-Type header manually.

What it means

Error "Empty request body. For file uploads, use multipart/form-data content type with a file field. When using curl with --form/-F, do NOT set the Content-Type header manually." thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/ocr_endpoints/endpoints.py:148

    # --- JSON body (existing behavior) ---
    try:
        body = await request.body()
    except RuntimeError:
        # Body stream was consumed by auth middleware (e.g., form parsing).
        body = b""

    if not body:
        # The body may be empty because the auth middleware already parsed
        # it as form data (e.g., _read_request_body called request.form()).
        # Check if form data is available.
        if getattr(request, "_form", None) is not None:
            verbose_proxy_logger.debug(
                "OCR request body is empty but form data is available from middleware — processing as multipart form."
            )
            return await _parse_multipart_form(request)

        raise ValueError(
            "Empty request body. For file uploads, use multipart/form-data content type "
            "with a file field. When using curl with --form/-F, do NOT set the Content-Type "
            "header manually."
        )

    try:
        data: Final = orjson.loads(body)
    except orjson.JSONDecodeError as e:
        raise ValueError(
            f"Invalid JSON in request body: {e}. "
            "Ensure the request body is valid JSON with Content-Type: application/json, "
            "or use multipart/form-data for file uploads."
        )

    # Security: reject type="file" documents received via JSON.
    # The "file" document type is designed for local SDK usage where the
    # caller and the process share a filesystem.  In the proxy context the
    # caller is remote, so allowing a file-path string would let an

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Send multipart/form-data with a file field (with curl --form/-F do not set Content-Type manually), or a valid JSON body.

When it happens

Trigger: Thrown at litellm/proxy/ocr_endpoints/endpoints.py:148 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/f7f98f8dd0688ad0. Report an issue: GitHub.