BerriAI/litellm · error · HTTPException

Cursor API key not found. Add Cursor credentials via the UI

Error message

Cursor API key not found. Add Cursor credentials via the UI (Models + Endpoints → LLM Credentials) or set CURSOR_API_KEY environment variable.

What it means

Guard in the Cursor pass-through: neither the credential router nor any entry in litellm.credential_list yielded a Cursor API key, and CURSOR_API_KEY is not set in the environment — so requests to api.cursor.com cannot be authenticated.

Source

Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:2204

    base_target_url = os.getenv("CURSOR_API_BASE") or "https://api.cursor.com"

    cursor_api_key = passthrough_endpoint_router.get_credentials(
        custom_llm_provider="cursor",
        region_name=None,
    )

    if cursor_api_key is None:
        for credential in litellm.credential_list:
            if credential.credential_info and credential.credential_info.get("custom_llm_provider") == "cursor":
                cursor_api_key = credential.credential_values.get("api_key")
                credential_api_base = credential.credential_values.get("api_base")
                if credential_api_base:
                    base_target_url = credential_api_base
                break

    if cursor_api_key is None:
        raise HTTPException(
            status_code=401,
            detail="Cursor API key not found. Add Cursor credentials via the UI (Models + Endpoints → LLM Credentials) or set CURSOR_API_KEY environment variable.",
        )

    encoded_endpoint = httpx.URL(endpoint).path

    if not encoded_endpoint.startswith("/"):
        encoded_endpoint = "/" + encoded_endpoint

    base_url: Final = httpx.URL(base_target_url)
    updated_url: Final = base_url.copy_with(
        path=HttpPassThroughEndpointHelpers.join_base_and_endpoint_path(base_url, encoded_endpoint)
    )

    auth_value: Final = base64.b64encode(f"{cursor_api_key}:".encode()).decode("ascii")

    endpoint_func: Final = create_pass_through_route(
        endpoint=endpoint,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set CURSOR_API_KEY in the proxy environment.
  2. Or add Cursor credentials in the Admin UI under Models + Endpoints → LLM Credentials.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:2204 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/4598bf9c12d7751d. Report an issue: GitHub.