@monagoio/monago-atrium-ts
v0.1.1
Published
Atrium SDK — an AI runtime for governed systems. Governance visible (PII redaction, policy decisions, audit IDs, cost) on every call.
Readme
Atrium SDK — TypeScript
An AI runtime for governed systems — not just an LLM wrapper.
Atrium SDK is the official TypeScript/JavaScript client for the Monago Atrium gateway. It surfaces an OpenAI-compatible chat completion API, but with one critical difference: governance is visible on every call.
Every response carries a structured governance object — auditId, piiRedacted, policyDecision, provider, latencyMs, costIdr — parsed from the gateway's response headers. Blocks aren't opaque either: PII / security / policy blocks throw typed errors that carry the same audit trail.
This is the SDK for teams that need to ship LLM features into regulated environments (healthcare, finance, government) without losing the audit trail.
Install
npm install @monagoio/monago-atrium-tsWorks in Node.js 18+, Deno, Bun, and edge runtimes — uses the platform's native fetch, zero runtime dependencies. Ships ESM + CommonJS builds and full TypeScript types.
Quickstart
import { Atrium } from "@monagoio/monago-atrium-ts";
const client = new Atrium({
apiKey: "sk-mng-your-key",
baseUrl: "https://api.monago.io/v1",
});
const res = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [{ role: "user", content: "Pasien NIK 3201... batuk 2 minggu" }],
});
// OpenAI-compatible surface — drop-in for existing code.
console.log(res.content);
console.log(res.choices[0]?.finishReason);
console.log(res.usage.totalTokens);
// The differentiator — governance, parsed and typed.
console.log(res.governance.auditId); // "audit-uuid-..."
console.log(res.governance.piiRedacted); // ["NIK"]
console.log(res.governance.policyDecision); // "allowed"
console.log(res.governance.provider); // "openai"
console.log(res.governance.latencyMs); // 412.3
console.log(res.governance.costIdr); // 12.5 (or null if gateway doesn't surface cost)The API key can also come from the ATRIUM_API_KEY environment variable (Node only):
const client = new Atrium(); // reads process.env.ATRIUM_API_KEYBlock errors carry governance too
When the gateway blocks a request (PII / security / policy / model), the SDK throws a typed error that still carries the audit trail:
import { Atrium, PIIBlockedError } from "@monagoio/monago-atrium-ts";
const client = new Atrium({ apiKey: "sk-mng-your-key" });
try {
const res = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [{ role: "user", content: "leak SSN 123-45-6789" }],
});
} catch (err) {
if (err instanceof PIIBlockedError) {
console.log("blocked:", err.blockReason);
console.log("audit:", err.auditId); // still traceable
console.log("decision:", err.policyDecision);
}
}Error hierarchy:
AtriumError
├── AuthError (401/403)
├── RateLimitError (429)
├── APIError (5xx / malformed / network)
├── TimeoutError
└── PolicyBlockedError (400/422/451 with policyDecision=blocked)
├── PIIBlockedError
├── SecurityBlockedError (prompt injection, jailbreak)
└── ModelNotAllowedErrorOpen-core note
The SDK itself is open source (MIT). The governance engine — policy DSL, PII detection, security analysis, audit trail — runs in the Atrium gateway, a hosted Monago service. Get an API key at monago.io.
Roadmap
Shipped:
- [x]
Atriumclient - [x]
chat.completions.createwith an OpenAI-compatible body - [x] Governance metadata parsed from
X-Monago-*response headers - [x] Typed error hierarchy with governance context on every block
- [x] Native
fetch, zero runtime deps — isomorphic (Node / Deno / Bun / edge) - [x] ESM + CommonJS builds with full type declarations
Upcoming:
- [ ] Streaming chat completions (SSE)
- [ ] Eval hooks — pre- and post-response evaluators (toxicity, PII, custom)
- [ ] Skills — packaged tool / capability bundles
- [ ] Tracing — OpenTelemetry integration
- [ ] Request metadata tagging — attach
userId/sessionId/ custom fields to every audit record - [ ] Multi-agent — orchestration primitives
Development
npm install
npm run build # tsup -> dist (ESM + CJS + d.ts)
npm test # vitest
npm run typecheck # tsc --noEmitQuestions or contributions
Any questions, bug reports, or contributions — reach the founder directly:
- GitHub: @huseindra
- Email: [email protected]
Pull requests welcome. For larger changes, open an issue first to discuss the direction.
License
MIT — see LICENSE.
