One endpoint
Use an OpenAI-compatible API endpoint from your application.
Connect your application to an OpenAI-compatible LLM gateway, then manage model access, request routing, and operational visibility through one integration.
Use an OpenAI-compatible API endpoint from your application.
Use available models through the same application integration.
Centralize request visibility, usage controls, and guardrails.
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);
Store API keys in environment variables or a secrets manager.
Set timeouts, retry transient failures, and return useful API errors.
Review request patterns and apply controls appropriate to your team.