Skip to content

Connect AI Coding Tools

Use PrimeRouter as your "private OpenAI / Anthropic API" inside any AI coding tool. This section has a dedicated page per tool, each with macOS / Linux / Windows commands.

Tools at a glance

ToolFormProtocolDocs
Claude CodeCLIAnthropic MessagesSetup →
OpenClawCLI / Gateway / AgentAnthropic CompatibleSetup →
OpenCodeCLI / TUIOpenAI CompatibleSetup →
CursorIDEOpenAI CompatibleSetup →
ClineVS Code / Cursor extensionOpenAI CompatibleSetup →
CrushCLI / TUIOpenAI CompatibleSetup →
Codex Setup GuideWindows / macOSOpenAI Responses / ChatSetup →
Codex CLICLIOpenAI Responses / ChatSetup →
VibecodeWeb / DesktopOpenAI CompatibleSetup →

Protocol compatibility

PrimeRouter exposes two protocols:

ProtocolEndpoint
OpenAI Compatiblehttps://primerouter.ai/v1
Anthropic Messageshttps://primerouter.ai (tool appends /v1/messages)

Most tools use OpenAI; Claude Code uses Anthropic.


Common setup (once)

1. Sign up + get an API key

  1. Visit primerouter.ai → sign up
  2. Console → Tokens → Add token → pick a group → Save
  3. Copy sk-xxx — referred to below as sk-your-primerouter-key.

2. The three parameters every tool needs

ParamValue
Base URLhttps://primerouter.ai/v1
API Keythe sk-xxx from above
Model IDany model id, e.g. claude-sonnet-4-6, claude-opus-4-7
Model IDBest for
claude-sonnet-4-6daily coding assistant, default pick
claude-opus-4-6stable Opus for complex tasks
claude-opus-4-7complex reasoning, long-context refactor

Full list at Available models.


Smoke test

After configuring any tool, verify the key + base URL with a one-liner:

bash
curl https://primerouter.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-primerouter-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [{"role":"user","content":"ping"}],
    "max_tokens": 10
  }'
powershell
curl.exe https://primerouter.ai/v1/chat/completions `
  -H "Authorization: Bearer sk-your-primerouter-key" `
  -H "Content-Type: application/json" `
  -d '{\"model\":\"claude-sonnet-4-6\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}],\"max_tokens\":10}'

Expect a choices[0].message.content field in the response. If you get a 4xx:

ErrorCauseFix
401 invalid_api_keyKey typo or disabledConsole → Tokens → check status
403 no_permissionToken group ≠ channel groupEdit token, add to the right group
404 model_not_foundWrong model id or group can't access itCheck Available models
429 too_many_requestsRate-limitedUpgrade plan / change group
500/502Upstream transient failureCheck primerouter.ai status

Streaming vs non-streaming

All listed tools use streaming (SSE) by default. If a tool hangs:

  • Disable streaming in tool settings to isolate the issue
  • Check PrimeRouter Console → Logs to see if the request actually arrived
  • If it arrived but the response is slow, upstream may be in cooldown — try another model

Costs and billing

  • PrimeRouter bills by actual token usage; every call is visible in Console → Logs
  • Claude family triggers Prompt Cache automatically (cache_ratio = 0.1, i.e. 90% discount on cache hits) — huge win for IDE/agent workflows
  • For long-context tools (Cline / Codex / Claude Code), claude-sonnet-4-6 is the sweet spot

Details at Billing rules.

Built for transparent, auditable, crypto-native AI inference. About · Terms · Privacy