nRouter developer quickstart

One API integration for production LLM applications.

Connect your application to an OpenAI-compatible LLM gateway, then manage model access, request routing, and operational visibility through one integration.

One endpoint

Use an OpenAI-compatible API endpoint from your application.

Model flexibility

Use available models through the same application integration.

Production controls

Centralize request visibility, usage controls, and guardrails.

Node.js example

Call nRouter with the OpenAI SDK

Keep your API key in a server-side environment variable. Never place it in browser code, a public repository, or this Space.

npm install openai

export NROUTER_API_KEY="your-nrouter-api-key"
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.NROUTER_API_KEY,
  baseURL: "https://api.nrouter.ai/v1"
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [
    { role: "user", content: "What is an LLM gateway?" }
  ]
});

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

Production checklist

Protect credentials

Store API keys in environment variables or a secrets manager.

Handle errors

Set timeouts, retry transient failures, and return useful API errors.

Monitor usage

Review request patterns and apply controls appropriate to your team.