Installation
Install the Nirmos SDK and configure a server-side client.
Install the Nirmos SDK
npm install @nirmos/sdkThe package ships ESM, CommonJS, and TypeScript declarations and requires Node.js 18 or newer.
Configure credentials
Create a Nirmos API key for the organization and environment your server will use.
NIRMOS_API_KEY=nirmos_your_keyKeep API keys on the server
Do not use NEXT_PUBLIC_, VITE_, or another browser-visible environment prefix. A Nirmos key can authorize model spend and access to organization resources.
Create one client
import { Nirmos } from "@nirmos/sdk";
export const nirmos = new Nirmos({
apiKey: process.env.NIRMOS_API_KEY!,
});Reuse the client in the process. Its managed-prompt cache is in memory and belongs to that instance.
Client options
| Option | Default | Purpose |
|---|---|---|
apiKey | required | Nirmos credential sent as x-api-key |
baseUrl | https://api.nirmos.com | API origin, without a required /v1 suffix |
timeoutMs | 60000 | Default request timeout; 0 disables it |
maxRetries | 2 | Retries for safe GETs and idempotent requests |
headers | none | Additional headers sent with every request |
promptCache | enabled | In-memory prompt cache configuration, or false |
fetch | globalThis.fetch | Custom fetch implementation |
Local or private deployment:
const nirmos = new Nirmos({
apiKey: process.env.NIRMOS_API_KEY!,
baseUrl: "http://localhost:4000",
timeoutMs: 30_000,
});OpenAI-compatible client
If your application already uses OpenAI's JavaScript SDK, install openai and point it at the Nirmos /v1 base URL:
import OpenAI from "openai";
export const client = new OpenAI({
baseURL: "https://api.nirmos.com/v1",
apiKey: process.env.NIRMOS_API_KEY!,
});Use the Nirmos SDK when you need managed prompts, normalized response metadata, or its streaming and error helpers. Use the OpenAI SDK for the gateway's OpenAI-compatible endpoints.
CommonJS
const { Nirmos } = require("@nirmos/sdk");
const nirmos = new Nirmos({
apiKey: process.env.NIRMOS_API_KEY,
});Continue to Quick Start to make a request.