BerriAI/litellm · error · ValueError

The proxy returned a non-JSON response from {start_url} (con

Error message

The proxy returned a non-JSON response from {start_url} (content-type: {content_type}). A proxy, load balancer, or auth gateway in front of LiteLLM may be intercepting the request. Response starts with: {response.text[:200]!r}

What it means

Error "The proxy returned a non-JSON response from {start_url} (content-type: {content_type}). A proxy, load balancer, or auth gateway in front of LiteLLM may be intercepting the request. Response starts with: {response.text[:200]!r}" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/client/cli/commands/auth.py:448

    if response.status_code in (404, 405):
        raise ValueError(
            f"POST {start_url} returned HTTP {response.status_code}. "
            "Either --base-url is wrong, or the proxy is older than this CLI and does not support "
            "the CLI SSO login flow; upgrade the proxy or use a CLI version that matches it."
        )
    if response.status_code != 200:
        detail: Final = _response_error_detail(response)
        raise ValueError(
            f"Starting CLI login failed: HTTP {response.status_code} from {start_url}"
            + (f": {detail}" if detail else "")
        )

    try:
        data: Final[CliSsoStartData] = response.json()
    except ValueError:
        content_type: Final = response.headers.get("content-type", "unknown")
        raise ValueError(
            f"The proxy returned a non-JSON response from {start_url} (content-type: {content_type}). "
            "A proxy, load balancer, or auth gateway in front of LiteLLM may be intercepting the request. "
            f"Response starts with: {response.text[:200]!r}"
        )

    required_fields: Final[tuple[str, ...]] = ("login_id", "poll_secret", "user_code")
    missing_fields: Final = tuple(field for field in required_fields if not isinstance(data.get(field), str))
    if missing_fields:
        raise ValueError(
            f"The response from {start_url} is missing required field(s): {', '.join(missing_fields)}. "
            "The proxy version may not match this CLI; upgrade whichever is older."
        )
    return data


def _get_cli_sso_poll_headers(poll_secret: str) -> dict[str, str]:
    return {"x-litellm-cli-poll-secret": poll_secret}

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check for an intercepting proxy/load balancer/auth gateway returning HTML instead of JSON.
  2. Bypass the interceptor or fix its configuration.

Example fix

curl -i $PROXY/... to inspect what the front-end proxy returns.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/client/cli/commands/auth.py:448 when the library encounters an invalid state.

Common situations: A middlebox returned a non-JSON response to the CLI login request.


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