{"record":{"id":"4598bf9c12d7751d","repo":"BerriAI/litellm","slug":"cursor-api-key-not-found-add-cursor-credentials-v","errorCode":null,"errorMessage":"Cursor API key not found. Add Cursor credentials via the UI (Models + Endpoints → LLM Credentials) or set CURSOR_API_KEY environment variable.","messagePattern":"Cursor API key not found\\. Add Cursor credentials via the UI \\(Models \\+ Endpoints → LLM Credentials\\) or set CURSOR_API_KEY environment variable\\.","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py","lineNumber":2204,"sourceCode":"\n    base_target_url = os.getenv(\"CURSOR_API_BASE\") or \"https://api.cursor.com\"\n\n    cursor_api_key = passthrough_endpoint_router.get_credentials(\n        custom_llm_provider=\"cursor\",\n        region_name=None,\n    )\n\n    if cursor_api_key is None:\n        for credential in litellm.credential_list:\n            if credential.credential_info and credential.credential_info.get(\"custom_llm_provider\") == \"cursor\":\n                cursor_api_key = credential.credential_values.get(\"api_key\")\n                credential_api_base = credential.credential_values.get(\"api_base\")\n                if credential_api_base:\n                    base_target_url = credential_api_base\n                break\n\n    if cursor_api_key is None:\n        raise HTTPException(\n            status_code=401,\n            detail=\"Cursor API key not found. Add Cursor credentials via the UI (Models + Endpoints → LLM Credentials) or set CURSOR_API_KEY environment variable.\",\n        )\n\n    encoded_endpoint = httpx.URL(endpoint).path\n\n    if not encoded_endpoint.startswith(\"/\"):\n        encoded_endpoint = \"/\" + encoded_endpoint\n\n    base_url: Final = httpx.URL(base_target_url)\n    updated_url: Final = base_url.copy_with(\n        path=HttpPassThroughEndpointHelpers.join_base_and_endpoint_path(base_url, encoded_endpoint)\n    )\n\n    auth_value: Final = base64.b64encode(f\"{cursor_api_key}:\".encode()).decode(\"ascii\")\n\n    endpoint_func: Final = create_pass_through_route(\n        endpoint=endpoint,","sourceCodeStart":2186,"sourceCodeEnd":2222,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py#L2186-L2222","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:2204 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set CURSOR_API_KEY in the proxy environment.","Or add Cursor credentials in the Admin UI under Models + Endpoints → LLM Credentials."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}