Get started
Quickstart
Create a key, send your first request, and let the router pick the best model. If you already use the OpenAI SDK, you only change the base URL and key.
1. Create an API key
In your workspace, go to Settings → API Keys and create a key. Keys are prefixed sk-nr- and shown once , copy it immediately and store it as an environment variable.
export NEURALROUTER_API_KEY="sk-nr-..."2. Send your first request
Set model to "auto" and the router selects a model for your objective. Pin a specific id (e.g. "claude-sonnet") to bypass routing.
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",
"messages": [
{ "role": "user", "content": "Explain inference routing in one sentence." }
]
}'3. Use an SDK
The official OpenAI SDKs work as a drop-in:
from openai import OpenAI
client = OpenAI(
base_url="https://api.neuralrouter.ai/v1",
api_key="sk-nr-...", # your Neural Router key
)
resp = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Hello!"}],
extra_headers={"X-NR-Objective": "lowest-latency"},
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.neuralrouter.ai/v1",
apiKey: process.env.NEURALROUTER_API_KEY,
});
const resp = await client.chat.completions.create(
{
model: "auto",
messages: [{ role: "user", content: "Hello!" }],
},
{
headers: {
"X-NR-Objective": "highest-quality",
"X-NR-Allow": "gpt-4o,claude-sonnet",
},
},
);
console.log(resp.choices[0].message.content);Authentication
Authenticate every request with your workspace key as a bearer token. Keys are scoped to a single workspace and inherit its budgets, guardrails, and residency policy. Revoking a key takes effect immediately; never embed a key in client-side code.
Authorization: Bearer sk-nr-xxxxxxxxxxxxxxxxxxxxNext
Learn how the router picks a model in Model routing, or see every parameter in the API reference.