Nirmos

Installation

Install the Nirmos SDK and configure a server-side client.

Install the Nirmos SDK

npm install @nirmos/sdk

The 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.

.env
NIRMOS_API_KEY=nirmos_your_key

Keep 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

lib/nirmos.ts
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

OptionDefaultPurpose
apiKeyrequiredNirmos credential sent as x-api-key
baseUrlhttps://api.nirmos.comAPI origin, without a required /v1 suffix
timeoutMs60000Default request timeout; 0 disables it
maxRetries2Retries for safe GETs and idempotent requests
headersnoneAdditional headers sent with every request
promptCacheenabledIn-memory prompt cache configuration, or false
fetchglobalThis.fetchCustom 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.

On this page