cursor-sdk2api
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Warn
- network request — Outbound network request in integrations/new-api/docker-compose.yml
- process.env — Environment variable access in integrations/new-api/smoke.mjs
- network request — Outbound network request in integrations/new-api/smoke.mjs
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Official Cursor SDK to Anthropic-compatible HTTP gateway with native MCP tool continuation.
cursor-sdk2api
The official Cursor SDK, on the APIs your agents already speak.
cursor-sdk2api turns the published @cursor/sdk into Anthropic Messages, OpenAI Chat Completions, and OpenAI Responses APIs. It uses the official Cursor Agent harness, not browser cookies, private transports, or CLI session scraping.
Highlights
Claude Code via
/v1/messages: SSE, tools, parallel and multi-round continuation, cache usage, resume, token estimate.Grok Build via
/v1/responses: streaming, function tools, continuation, reasoning usage.Codex / Responses clients via
/v1/responses: Responses contract, function tools, streaming.OpenAI SDK via
/v1/chat/completions: chat, streaming, tools.Claude 1M mode: when Cursor's live catalog exposes
context=1m, including on Sonnet 4.6 and Fable 5, the official SDK parameter is forwarded unchanged.Native client tools: filesystem, shell, web, and network tools stay in Claude Code, Grok, or Codex and run in your local workspace.
One tool engine: all three protocols share the same Cursor SDK run, parallel-tool, continuation, replay, and session coordinator.
One gateway key, many accounts: persistent Cursor account pool, model-aware round-robin, session-sticky continuation, Dashboard quota, web console, and Docker.
new-api integrated: ready-made external deployment, channel templates, compose E2E, and acceptance smoke. Open the new-api guide.
Cursor-routed Grok does not provide xAI-native
x_search. Client-owned web and network tools still work as normal function tools.
Quick start
Requires Node.js 22.19 or newer, one gateway key, and at least one Cursor User API Key to import.
git clone https://github.com/Sunnyender-org/cursor-sdk2api.git
cd cursor-sdk2api
npm ci
npm run build
AUTH_MODE=managed GATEWAY_ACCESS_KEY='replace-me' node dist/index.js
Open http://localhost:8080/console/, import one or more Cursor accounts, then call every account through the same gateway key:
curl http://localhost:8080/v1/models \
-H "Authorization: Bearer $GATEWAY_ACCESS_KEY"
Docker:
docker compose up --build
If Cursor needs a proxy, set HTTP_PROXY, HTTPS_PROXY, and NO_PROXY. The gateway applies them to both SDK data planes. SOCKS and PAC URLs fail closed.
Client setup
Claude Code
export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
export ANTHROPIC_AUTH_TOKEN="$GATEWAY_ACCESS_KEY"
export ANTHROPIC_MODEL=claude-sonnet-4-6
claude
Grok Build
[model.cursor]
name = "cursor-sdk2api"
base_url = "http://127.0.0.1:8080/v1"
api_key = "<gateway-key>"
model = "grok-4.6"
api_backend = "responses"
Codex
model = "composer-2.5"
model_provider = "cursor-sdk2api"
[model_providers.cursor-sdk2api]
name = "cursor-sdk2api"
base_url = "http://127.0.0.1:8080/v1"
wire_api = "responses"
env_key = "GATEWAY_ACCESS_KEY"
Responses clients that require previous_response_id, stored response objects, or hosted OpenAI tools are not supported yet.
Tools and search
Client tools are converted to SDK local.customTools through MCP. The model chooses tools through Cursor's harness, while the outer client executes them in its own workspace.
- Supported: Claude Code, Grok, and Codex local tools, including client-owned web or network search.
- Disabled: Cursor ambient shell, read, edit, task,
webSearch, andwebFetch. - Not available on this route: xAI
x_search. - Not implemented: hosted OpenAI
web_search,file_search, andcomputer.
Operations
/console/: local operator console/v1/models: live Cursor model catalog/v1/account: pooled Cursor identities and current Dashboard usage in managed mode/health: capabilities, SDK version, and proxy transport modeSTATE_DIR: account, SDK store, and resume state
Managed mode follows CPA's split between client keys and upstream credentials: clients receive only GATEWAY_ACCESS_KEY; imported Cursor keys stay in the gateway account store. New sessions use model-aware round-robin, while tool continuation and resume stay pinned to the original account. BYOK remains available for a trusted single-user sidecar.
v0.1 is a trusted single-process sidecar. The management account endpoint has no separate authentication. Imported Cursor keys are stored in owner-only state files and are never returned to the browser after import. The supplied compose files bind the console to loopback; authenticate and restrict /console/ plus /v0/management/* at any Internet-facing proxy.
Verification
The deterministic suite contains 167 tests. The dated, redacted live receipt covers Sonnet 4.6, Fable 5, Composer 2.5, and Grok 4.6 xhigh: live smoke evidence.
npm run typecheck
npm test
npm run build
Documentation
MIT licensed. @cursor/sdk remains subject to its own license and Cursor's Terms. This project is not affiliated with Cursor or Anysphere.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found