@enatlas/sdk
v0.1.1
Published
EnAtlas SDK — In-process AI spend monitoring, caching & optimization for Node.js
Maintainers
Readme
@enatlas/sdk
EnAtlas SDK — In-process AI spend monitoring, caching & optimization for Node.js.
Wrap your OpenAI client to get automatic telemetry, exact-match caching, request coalescing, model routing, and resilience routing — all without a sidecar proxy.
Install
npm install @enatlas/sdkQuick Start
import OpenAI from 'openai';
import { wrapOpenAI } from '@enatlas/sdk';
const openai = new OpenAI();
const { client, destroy } = wrapOpenAI(openai, {
cloudIngestUrl: 'https://www.enatlas.com/api/ingest/events',
workspaceIngestKey: 'en_your_key',
workspaceId: 'your-workspace-id',
});
// Use client as normal — monitoring is automatic
const res = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello' }],
});
// Clean up on shutdown
destroy();Features
- Automatic telemetry — Latency, tokens, cost, errors tracked per request
- Exact-match caching — Identical prompts served from memory in <1ms
- Request coalescing — Concurrent duplicate requests collapsed into one upstream call
- Model routing — Downgrade models based on dashboard policies
- Resilience routing — Automatic failover to backup provider on 429/5xx
- Async telemetry — Never blocks your API calls
- Per-instance isolation — Safe for multi-tenant and multi-client usage
Configuration
const { client, destroy } = wrapOpenAI(openai, {
// Required — connects to your EnAtlas dashboard
cloudIngestUrl: 'https://www.enatlas.com/api/ingest/events',
workspaceIngestKey: 'en_...',
workspaceId: 'uuid',
// Optional
integrationName: 'openai', // Provider name for tagging
maxCacheSize: 500, // Max cache entries (FIFO eviction)
});Trust Model
- Your API keys never leave your process.
- Prompts and completions are never sent to EnAtlas cloud.
- Only metadata (model, tokens, latency, cost) is sent as telemetry.
- Telemetry is async and never blocks your API calls.
When to Use SDK vs Sidecar
| | SDK | Sidecar |
|---|-----|---------|
| Setup | npm install + wrap client | npx @enatlas/sidecar init |
| Languages | Node.js only | Any (HTTP proxy) |
| Latency | Zero network hops | 1 local hop |
| Best for | Node.js apps wanting lowest overhead | Multi-language stacks, OpenClaw configs |
Both connect to the same dashboard and support the same optimization policies. You can switch between them without reintegration.
License
MIT
