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
| Tool | Form | Protocol | Docs |
|---|---|---|---|
| Claude Code | CLI | Anthropic Messages | Setup → |
| OpenClaw | CLI / Gateway / Agent | Anthropic Compatible | Setup → |
| OpenCode | CLI / TUI | OpenAI Compatible | Setup → |
| Cursor | IDE | OpenAI Compatible | Setup → |
| Cline | VS Code / Cursor extension | OpenAI Compatible | Setup → |
| Crush | CLI / TUI | OpenAI Compatible | Setup → |
| Codex Setup Guide | Windows / macOS | OpenAI Responses / Chat | Setup → |
| Codex CLI | CLI | OpenAI Responses / Chat | Setup → |
| Vibecode | Web / Desktop | OpenAI Compatible | Setup → |
Protocol compatibility
PrimeRouter exposes two protocols:
| Protocol | Endpoint |
|---|---|
| OpenAI Compatible | https://primerouter.ai/v1 |
| Anthropic Messages | https://primerouter.ai (tool appends /v1/messages) |
Most tools use OpenAI; Claude Code uses Anthropic.
Common setup (once)
1. Sign up + get an API key
- Visit primerouter.ai → sign up
- Console → Tokens → Add token → pick a group → Save
- Copy
sk-xxx— referred to below assk-your-primerouter-key.
2. The three parameters every tool needs
| Param | Value |
|---|---|
| Base URL | https://primerouter.ai/v1 |
| API Key | the sk-xxx from above |
| Model ID | any model id, e.g. claude-sonnet-4-6, claude-opus-4-7 |
3. Recommended Claude model IDs
| Model ID | Best for |
|---|---|
claude-sonnet-4-6 | daily coding assistant, default pick |
claude-opus-4-6 | stable Opus for complex tasks |
claude-opus-4-7 | complex 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:
| Error | Cause | Fix |
|---|---|---|
401 invalid_api_key | Key typo or disabled | Console → Tokens → check status |
403 no_permission | Token group ≠ channel group | Edit token, add to the right group |
404 model_not_found | Wrong model id or group can't access it | Check Available models |
429 too_many_requests | Rate-limited | Upgrade plan / change group |
500/502 | Upstream transient failure | Check 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-6is the sweet spot
Details at Billing rules.
