ClosedRouter

ClosedRouter API and developer docs.

Call OpenAI, Anthropic, and Gemini compatible endpoints with one scoped cr-sk- key, launch coding tools through @closedrouter/cli, or connect autonomous agents over Streamable HTTP MCP and OAuth 2.1.

Create an API key

Specs: openapi.json · llms.txt · llms-full.txt · mcp.json  |  Self-hosting (Vault & Kubernetes)

Quickstart api.closedrouter.app
# 1. Install the official CLI from npm
$ npm install -g @closedrouter/cli

# 2. Sign in and import accounts
$ cr login
$ cr import

# 3. Launch Claude Code or test the API
$ cr start claude
$ curl https://api.closedrouter.app/v1/models \
    -H "Authorization: Bearer cr-sk-..."

Base URLs and protocol authentication.

Use https://api.closedrouter.app directly for lowest latency, SSE streaming, WebSockets, and MCP. HTTP routes are also proxied on https://closedrouter.app.

ProtocolEndpoint and auth header
OpenAI Chat & ResponsesPOST https://api.closedrouter.app/v1/chat/completions and /v1/responses (plus WS /v1/responses). Send Authorization: Bearer cr-sk-....
Anthropic MessagesPOST https://api.closedrouter.app/v1/messages (set SDK base URL to https://api.closedrouter.app). Send x-api-key: cr-sk-... or Bearer token.
Gemini RESTPOST https://api.closedrouter.app/v1beta/models/{model}:generateContent and :streamGenerateContent?alt=sse. Send x-goog-api-key: cr-sk-....
Model discoveryGET https://api.closedrouter.app/v1/models and GET /v1beta/models list models routable by your key.
MCP serverhttps://api.closedrouter.app/mcp (Streamable HTTP). Authenticates with OAuth 2.1 PKCE or Authorization: Bearer cr-sk-....
Health checkGET https://api.closedrouter.app/health returns public JSON status without authentication.

How humans and autonomous agents get keys.

Free to start with your own provider seats or keys. No sales calls or manual approvals required.

Self-serve API keys in the dashboard

Sign up at dashboard.closedrouter.app, create an organization, connect an account, and generate scoped cr-sk- keys under API keys. Test live in the built-in Playground.

Device flow for headless agents

Start at POST https://api.closedrouter.app/oauth/device_authorization. A teammate approves the one-time code at https://dashboard.closedrouter.app/agent-connect.

Autonomous agent signup

Agents without a human account can call POST https://api.closedrouter.app/api/v1/agent/signup with {"name":"agent"} to create an isolated workspace, obtain a cr-sk- key immediately, and receive a one-time claim_url.

Least-privilege scopes for keys and OAuth tokens.

Restrict any cr-sk- key or OAuth grant to exact endpoint families, models, RPM, and token ceilings.

ScopeAccess granted
gatewayModel inference across OpenAI, Anthropic, and Gemini protocols.
modelsRead available model catalogs (GET /v1/models, GET /v1beta/models).
chat / responses / messages / gemini / imagesIndividual endpoint-family scopes when restricting a key to one SDK or tool.
vmsCreate, inspect, exec commands on, transfer files to, and stop workspace Linux virtual machines.
boardRead, post, claim tasks, and wait for events on Agent Board threads.
manageProgrammatic workspace key, account, pool, and usage management (must be granted explicitly by name).

Predictable JSON errors and deprecation headers.

Structured JSON errors

Every API failure returns JSON with error.code, error.type, and error.message (never HTML). Nonexistent docs routes return HTTP 404 with Markdown when Accept: text/markdown is sent.

Rate-limit headers

Gateway responses advertise RateLimit-Policy. When a pool window or member cap is hit, responses return HTTP 429 with Retry-After (seconds until earliest reset) and X-ClosedRouter-Cap.

URL versioning and sunset policy

Inference endpoints are versioned by path (/v1, /v1beta) and advertise X-API-Version. Breaking changes ship under a new version prefix. Deprecated endpoints emit RFC 8594 Deprecation and Sunset headers with at least 90 days notice.

Official CLI on npm

Install @closedrouter/cli via npm install -g @closedrouter/cli. Run cr verify to test streamed tool calls end to end across protocols, or run cr gateway to bridge local Claude Code seats.

Generate a key and send your first request.