@noburn/sdk weekly downloads statistics
Hard LLM spend enforcement for Node.js — pre-call budget checks and per-user metering.
@noburn/sdk has 419 recorded weekly downloads on npm, a decrease of 61.2% over the past 30 days, ranking #2304 of 3,247 tracked listings.
About @noburn/sdk
@noburn/sdk
Hard LLM spend enforcement for Node.js — pre-call budget checks and per-user metering.
Check a planned LLM call against project-, per-user-, and per-run budget caps before you make it, then record what it actually cost.
Install
npm install @noburn/sdk
Requires Node.js ≥ 18 (uses the global fetch).
Quick start
import { NoburnGuard } from '@noburn/sdk';
const guard = new NoburnGuard({
apiKey: process.env.NOBURN_API_KEY!,
projectId: process.env.NOBURN_PROJECT_ID!,
budgetCapUsd: 10, // optional local fallback cap
onError: 'allow', // 'allow' (default, fail-open) | 'block' (fail-closed)
});
const decision = await guard.check({
model: 'gpt-4o',
estimatedTokensIn: 1000,
estimatedTokensOut: 300,
endUserId: 'user_123', // optional — enforces that user's cap
});
if (decision.blocked) {
throw new Error(`Blocked by noburn: ${decision.blockReason}`);
}
// ... make your LLM call ...
await guard.record({
model: 'gpt-4o',
tokensIn: 980,
tokensOut: 290,
costUsd: 0.005,
wasBlocked: false,
endUserId: 'user_123',
});
record() is fire-and-forget — it returns immediately and never throws, so it
adds no latency to your call path.
Usage quotas
Give each plan an allowance ("free gets 20 requests a day") in the dashboard
under Plan quotas, then pass the user's plan in context.plan:
const decision = await guard.check({
model: 'gpt-4o',
estimatedTokensIn: 1000,
estimatedTokensOut: 300,
endUserId: 'user_123',
context: { plan: 'free' },
});
if (decision.blockReason === 'quota_exceeded' && decision.quota?.upgradeSuggested) {
// show your upgrade prompt
}
// Show the allowance before the user tries anything:
const q = await guard.remaining({ endUserId: 'user_123', plan: 'free' });
if (q) console.log(`${q.remaining} of ${q.limit} left, resets ${q.resetsAt}`);
remaining() returns null when no quota applies or on any network error, and
only throws NoburnAuthError. Windows are UTC (day 00:00, week Monday 00:00,
month the 1st). A per-user cap set in the dashboard overrides the plan quota.
Per-customer budgets
Set each customer's cap from your backend: on signup, upgrade, top-up or cancel. Turn on Can manage budgets for the key first (project → SDK key).
await guard.setEndUserBudget({ endUserId: 'ws_123', limit: 20 }); // $20 / month
await guard.setEndUserBudget({ endUserId: 'ws_123', limit: 5, window: 'total' }); // never resets
await guard.setEndUserBudget({ endUserId: 'ws_123', limit: 5, window: 'total', resetSpend: true }); // fresh pool
await guard.setEndUserBudgets([{ endUserId: 'ws_1', limit: 5 }, { endUserId: 'ws_2', limit: 20 }]); // up to 500
const b = await guard.getEndUserBudget('ws_123'); // { limit, used, remaining, ... } or null
await guard.deleteEndUserBudget('ws_123');
Unlike check(), these throw (NoburnApiError with status and code), so a
cap you meant to set never silently goes missing. Changes apply on the
customer's next check(). Docs: https://noburn.dev/docs/per-customer-budgets
Agent runs
Bound a single agent invocation with its own cap:
const run = await guard.startRun({ budgetCapUsd: 0.5 });
const decision = await guard.check({
model: 'gpt-4o',
estimatedTokensIn: 1000,
estimatedTokensOut: 300,
runId: run.runId,
});
await guard.record({ /* ... */, runId: run.runId });
const summary = await guard.endRun(run.runId); // { status, spendUsd, ... }
Stopping a run
Stop a runaway run from outside the agent: a supervisor, a spend.spike
webhook handler, or the dashboard's Stop run button. Every later check()
for that run returns { blocked: true, blockReason: 'run_stopped' }.
const stopped = await guard.stopRun(runId, { reason: 'spend spike' });
// { runId, status: 'stopped', stoppedNow, spendUsd, stoppedAt, stoppedReason, ... } | null
Stopping is idempotent (stoppedNow: false when it was already stopped). It
returns null on a network error or an unknown run, and throws only
NoburnAuthError. If this guard has seen a run stopped, check() keeps
blocking it even while the noburn API is unreachable.
Profit per customer
Send what each end user pays you, and the project's Customers page shows
revenue, AI cost and margin per customer, money-losing customers first. Use the
exact endUserId you pass to check() / record() (it is not trimmed).
await guard.recordRevenue({
endUserId: 'user_abc123',
amountUsd: 49.0, // negative for refunds
occurredAt: '2026-10-01T09:30:00Z', // optional, defaults to now
externalId: invoice.id, // optional idempotency key (e.g. Stripe invoice id)
});
Like record(), it is fire-and-forget: queued and delivered in the background
with retry. A repeated externalId is ignored server-side, so webhook retries
never double-count. It never throws except NoburnAuthError, raised once a
previous delivery was rejected for an invalid key. That error is thrown
synchronously at the call, so void guard.recordRevenue(...) can't cause an
unhandled rejection. Invalid input, and revenue the server rejects with a 4xx,
are dropped and counted in droppedEventCount.
Before a short-lived process exits, call await guard.flush(), or
await guard.flush({ timeoutMs: 5000 }) to cap the wait. With a timeout it
returns without throwing, even if events are still queued. See the
profit-per-customer guide for a
Stripe invoice.paid webhook example.
Behavior…
Description from the npm listing.
- llm
- ai
- budget
- cost-control
- openai
- anthropic
- langchain
- vercel-ai-sdk
- ai-sdk
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (142)Similar npm AI SDKs plugins
All 20 @noburn/sdk alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@noburn/sdk. First seen Nov 11, 2026; last successful collection Nov 23, 2026. See the methodology.