Quick Start
Go from an API key to the first successful Nirmos request.
Set your API key
NIRMOS_API_KEY=nirmos_your_keyThe SDK does not read environment variables automatically. Pass the key from your server's secret store when you create a client.
Send a chat completion
Both examples call POST /v1/chat/completions with the same provider-qualified model.
import { Nirmos } from "@nirmos/sdk";
const nirmos = new Nirmos({
apiKey: process.env.NIRMOS_API_KEY!,
});
const completion = await nirmos.gateway.chat.create({
model: "openai/gpt-5.4-mini",
messages: [
{ role: "user", content: "Explain an AI gateway in two sentences." },
],
maxOutputTokens: 200,
});
console.log(completion.outputText);
console.log(completion.metadata.requestId);import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.nirmos.com/v1",
apiKey: process.env.NIRMOS_API_KEY!,
});
const completion = await client.chat.completions.create({
model: "openai/gpt-5.4-mini",
messages: [
{ role: "user", content: "Explain an AI gateway in two sentences." },
],
max_tokens: 200,
});
console.log(completion.choices[0]?.message.content);The Nirmos SDK returns normalized camelCase fields such as outputText and metadata. The OpenAI client returns the standard OpenAI response shape.
Route without changing providers in code
Create and activate a route named production-chat in Nirmos, then call it through either client:
const completion = await nirmos.gateway.chat.create({
route: "production-chat",
messages: [{ role: "user", content: "Summarize this incident." }],
});const completion = await client.chat.completions.create({
model: "nirmos/production-chat",
messages: [{ role: "user", content: "Summarize this incident." }],
});nirmos/production-chat is a virtual model name. The gateway resolves it to the active route with that slug.