BerriAI/litellm · error · ValueError

document type 'file' is not supported through the JSON API.

Error message

document type 'file' is not supported through the JSON API. To upload a local file, use multipart/form-data with a 'file' field. For JSON requests, use 'document_url' or 'image_url' document types.

What it means

Error "document type 'file' is not supported through the JSON API. To upload a local file, use multipart/form-data with a 'file' field. For JSON requests, use 'document_url' or 'image_url' document types." thrown in BerriAI/litellm.

Source

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

    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
    # authenticated user read arbitrary files from the server's filesystem.
    # File uploads must go through multipart/form-data instead.
    doc: Final = data.get("document") if isinstance(data, dict) else None
    if isinstance(doc, dict) and doc.get("type") == "file":
        raise ValueError(
            "document type 'file' is not supported through the JSON API. "
            "To upload a local file, use multipart/form-data with a 'file' field. "
            "For JSON requests, use 'document_url' or 'image_url' document types."
        )

    # Security: reject provider-native file IDs (e.g. reducto://) received via
    # JSON. These IDs are not scoped to the LiteLLM proxy user/key, so an
    # authenticated user who obtains another user's file ID could submit it
    # here and receive the OCR result using the proxy's shared provider
    # credentials. Force callers to upload fresh content per request via
    # multipart/form-data or an inline base64 data URI, both of which produce
    # a server-mediated upload bound to the current request.
    if isinstance(doc, dict):
        for url_field in ("document_url", "image_url"):
            url_value = doc.get(url_field)
            if isinstance(url_value, str) and url_value.startswith("reducto://"):
                raise ValueError(
                    "reducto:// file IDs are not accepted through the proxy "

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use multipart/form-data with a 'file' field for local files, or use 'document_url'/'image_url' document types for JSON requests.

When it happens

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