Browse documentation
Getting StartedQuick Start

Quick Start

Create an nRouter API key, set it in your environment, and send your first chat completions request in minutes with TypeScript, Python, or cURL.

Last updated

Make your first request in three steps: create an API key, set it in your environment, and call the chat completions endpoint.

Pick your pathBest forSetup
REST API (cURL / any HTTP client)Testing, scripts, any languageNo install — step 2, cURL tab
nRouter SDK (TypeScript / Python)A typed client for your appOne install — step 2 tabs
OpenAI SDK you already haveExisting OpenAI codeChange the base URL + key only

1. Create an API key

Create a virtual API key in the nRouter dashboard. Add credits to your account if needed, then set the key in your terminal:

export NROUTER_API_KEY="sk-nrouter-…"

In PowerShell, set it for the current terminal session with:

$env:NROUTER_API_KEY = "sk-nrouter-…"

Keep the key on your server. Do not include it in browser code or commit it to source control.

2. Send your first request

Choose a language tab. Each example sends the same request to https://api.nrouter.ai/v1/chat/completions. The SDKs and cURL example read the key from NROUTER_API_KEY.

npm install @nrouter_ai/sdk
import { nRouter } from "@nrouter_ai/sdk";

const client = new nRouter(); // reads NROUTER_API_KEY from the environment
const response = await client.chat.completions.create({
  model: "nrouter/auto",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0]?.message.content);

A working call returns a chat completion JSON — and the same request shows up in your dashboard's request logs within seconds, with the model that answered and its exact cost.

nrouter/auto lets nRouter choose the model for each request. To choose a specific model instead, use an ID from your live model catalog.

3. Continue building

Was this page helpful?