Get started
Coding tools
Neural Router is a drop-in endpoint for any OpenAI- or Anthropic-compatible coding tool. Configure a base URL, paste one key, and reach every model, or let the router pick the best one for each request.
How it works
Most coding tools, OpenCode, Cline, Continue, Cursor, Aider, and Claude Code, let you point at a custom "OpenAI-compatible" (or Anthropic-compatible) endpoint. Neural Router is that endpoint. You configure three things once:
- Base URL — where requests go (see the table below).
- API key — one Neural Router key, prefixed sk-nr-, drawn from your prepaid workspace balance.
- Model — a specific id (claude-sonnet) or a routing alias (auto) the tool sends as its "model".
From then on, the tool works exactly as it does with any provider, your key unlocks the whole catalog behind it, and every request is metered against your balance.
Base URLs
Pick the one that matches how your tool talks to models:
| Protocol | Base URL | Used by |
|---|---|---|
| OpenAI (chat completions) | https://api.neuralrouter.ai/v1 | OpenCode, Cline, Roo, Continue, Cursor, Aider, OpenAI SDKs |
| Anthropic (messages) | https://api.neuralrouter.ai | Claude Code, Anthropic SDKs |
The OpenAI base URL ends in /v1; the Anthropic base URL is the bare host (its SDK appends /v1/messages itself). Both accept the same sk-nr- key.
Get a key
In your workspace, open Settings → API Keys, create a key, and copy it once (it is shown only at creation). Load a balance under Credits, Neural Router is prepaid, so requests draw down credits and hard-stop at zero (no surprise bills). Then export it:
export NEURALROUTER_API_KEY="sk-nr-..."OpenCode
Add Neural Router as a custom provider in opencode.json (project root or ~/.config/opencode/). List whichever models or aliases you want to appear in the model switcher:
{
"provider": {
"neuralrouter": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.neuralrouter.ai/v1",
"apiKey": "{env:NEURALROUTER_API_KEY}"
},
"models": {
"auto": { "name": "Neural Router · auto (best value)" },
"best": { "name": "Neural Router · best quality" },
"fastest": { "name": "Neural Router · fastest" },
"claude-sonnet": { "name": "Claude Sonnet (pinned)" }
}
}
}
}Then pick a "Neural Router" model in OpenCode's switcher. auto lets the router choose; a pinned id (claude-sonnet) always uses that model.
Cline / Roo Code (VS Code)
In the extension's settings pane:
- API Provider: OpenAI Compatible
- Base URL: https://api.neuralrouter.ai/v1
- API Key: your sk-nr- key
- Model ID: auto (or a pinned id like gpt-4o)
Leave "Model supports images/computer use" on if you plan to use a vision-capable model, the router advertises the right capabilities per model.
Continue (VS Code / JetBrains)
Add Neural Router models to your Continue config. Use provider: openai with our apiBase:
# ~/.continue/config.yaml
models:
- name: Neural Router (auto)
provider: openai
apiBase: https://api.neuralrouter.ai/v1
apiKey: ${{ env.NEURALROUTER_API_KEY }}
model: auto
- name: Claude Sonnet (pinned)
provider: openai
apiBase: https://api.neuralrouter.ai/v1
apiKey: ${{ env.NEURALROUTER_API_KEY }}
model: claude-sonnetCursor
In Settings → Models, enable Override OpenAI Base URL and set it to https://api.neuralrouter.ai/v1, then paste your sk-nr- key as the OpenAI API key. Add a custom model named auto (or any pinned id) so Cursor sends it as the model.
Cursor validates the key against /v1/models, which Neural Router serves, so the "Verify" button succeeds.
Claude Code
Claude Code speaks the Anthropic Messages protocol. Point it at the bare host and hand it your Neural Router key, any Claude request then routes through Neural Router (with full tool-use and streaming):
# Point Claude Code at Neural Router's Anthropic-compatible endpoint.
# (No /v1 suffix — the Anthropic base URL is the bare host.)
export ANTHROPIC_BASE_URL="https://api.neuralrouter.ai"
export ANTHROPIC_AUTH_TOKEN="$NEURALROUTER_API_KEY"
# Optional: let the router choose the model instead of pinning one.
export ANTHROPIC_MODEL="auto"
claude # or launch your IDE extensionAider
Aider uses the OpenAI protocol; prefix the model with openai/ so it routes to the custom base URL:
# Aider speaks the OpenAI protocol. Prefix the model with "openai/".
export OPENAI_API_BASE="https://api.neuralrouter.ai/v1"
export OPENAI_API_KEY="$NEURALROUTER_API_KEY"
aider --model openai/auto
# or pin one:
aider --model openai/claude-sonnetChoosing a model
Whatever the tool calls its "model" field, you have three strategies, use whichever fits:
- Pin a specific model — send a concrete id like claude-sonnet, gpt-4o, or kimi-k2. If several providers serve that model, the router still load-balances across them for uptime and cost and fails over automatically, you get provider redundancy for free, without leaving your chosen model. See Provider routing.
- Use a routing alias — send auto (best value), best (highest quality), fastest (lowest latency/TTFT), or cheapest. The router scores every eligible model on live price, latency, TTFT, and quality and dispatches to the winner, per request. This is the best fit for agentic coding, where each step has different needs.
- Leave it to workspace policy — set a default objective and allow/deny lists in the console; every auto request inherits them, so you can change routing centrally without touching each tool.
See Model routing for objectives and the explainable "why this model" readout, and Models to browse every available id.
Temperature & other parameters
Every standard sampling parameter passes straight through, set it in the tool's settings or in the request body: temperature, top_p, max_tokens, stop, frequency_penalty, presence_penalty, plus tools/tool_choice and response_formatfor structured output. Neural Router translates them to each provider's native shape (including scaling Anthropic's 0–1 temperature range to the OpenAI 0–2 range) so the same request behaves consistently across models.
curl https://api.neuralrouter.ai/v1/chat/completions \
-H "Authorization: Bearer $NEURALROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "X-NR-Objective: quality-per-dollar" \
-d '{
"model": "auto",
"temperature": 0.2,
"messages": [
{ "role": "user", "content": "Refactor this function to be O(n)." }
]
}'Tools that don't expose a route field still get routing via the alias you pick as the model and your workspace objective, the route object is only needed for per-request overrides.
Billing & limits
Neural Router is prepaid only. Each request debits your workspace balance at the model's per-token price; when credits reach zero, requests return 402 Payment Required until you top up, there is no postpaid overdraft. Watch spend per model under Credits, and scope keys per workspace so a leaked key can only spend that workspace's balance. Revoking a key takes effect immediately; never commit a key to source control.
Next
New to the API? Start with the Quickstart. For every parameter and error code, see the API reference.