Versioning and compatibility
Use the current 0.3 client shape and review SDK upgrades deliberately.
These docs track @nirmos/sdk from the current SDK package; the generated reference records that version. Keep a lockfile and test representative workflows before upgrading. The package is pre-1.0; do not assume every minor version preserves the public surface.
Moving to 0.3
- Use
Nirmosfrom the package root. TheNirmosClientalias was removed. - Replace top-level
apiKeywithauth: { type: "api-key", key }. - Replace
baseUrlwith separateapiBaseUrlandruntimeBaseUrl. - Runtime prompt content/retrieve/render/cache methods live under
managedPrompts. - Management
promptsuses editor/branch DTOs and string version IDs. - Gateway chat, streaming and embedding calls remain under
gateway.
Compatibility boundaries
Import only package-root exports. This documentation covers operations supported for external API-key consumers. Private transport/cache/parser helpers are not public APIs. Public TypeScript types can contain accepted configuration values that runtime does not implement; consult feature limitations before relying on them.
Finish reasons and stream event strings are extensible. Read fields your application uses and safely ignore unfamiliar additive values. Management dates remain strings and broad optional DTO fields require guards.
SDK quickstart · TypeScript support · SDK reference
Runtime requirements
| Environment | Requirements |
|---|---|
| Node.js | Package engine: >=18; native Fetch globals and Web Streams |
| Browser | Fetch, Headers, Response, AbortController, ReadableStream, TextDecoder and FormData; crypto.randomUUID() for mutating runtime requests |
| Other JavaScript runtimes | Equivalent Web APIs; no Bun, Deno or Edge-specific SDK adapter or compatibility test suite |
| TypeScript | Included declarations; no peer requirement or declared minimum compiler version |
Use a Node release that supplies all required globals. Node 18 setups may need Web Crypto configuration; passing custom fetch does not polyfill Headers, Response, streams or crypto.
Module formats
The quickstart uses ES modules. CommonJS applications can load the same client with:
const { Nirmos, NirmosError } = require("@nirmos/sdk");Use the same constructor options and call asynchronous methods inside an async function in CommonJS. Import public types and errors from @nirmos/sdk; only the package root is exported.
SDK and HTTP integrations
| Integration | Use when | Boundary |
|---|---|---|
| Nirmos SDK | You need resource management, execution workflows, public DTOs, stable error classes and stream assembly | Nirmos-specific constructor/method/result shapes |
| OpenAI-compatible HTTP client | You already use the gateway's compatible chat/embeddings protocol | Does not expose Nirmos resource management or local prompt helpers |
| Provider-native client | You require a provider feature outside the implemented Nirmos contract | Provider-specific APIs and application-owned routing |
The Nirmos SDK exposes gateway.chat.create, gateway.chat.stream and gateway.embeddings.create, not OpenAI's chat.completions.create. It normalizes fields such as outputText and usage.inputTokens. Compatible HTTP uses wire fields such as max_tokens and standard choices. Do not interchange snippets between clients.
Production runtime mutations require fresh x-request-timestamp (Unix milliseconds) and x-request-nonce headers. The Nirmos SDK adds them automatically. A third-party HTTP client must supply them for each attempt; reusing a nonce for automatic retries can trigger replay rejection. Use your deployment's runtime origin with /v1 for an OpenAI client's base URL, rather than assuming the management API hosts inference.
For managed resources and local prompt rendering, use SDK methods documented here. Provider capabilities and runtime availability remain prerequisites for every inference path.
Before upgrading, test representative chat/stream cancellation, prompt reload/render, embeddings, endpoint validation and administrative workflows against your deployment. Compile public types and verify execution separately; declarations do not establish provider support.