@bursora/sdk
v0.2.0
Published
Bursora SDK: wrap your AI provider client to enforce per-customer and per-agent budgets, no proxy.
Maintainers
Readme
@bursora/sdk
Catch the runaway AI bill before it happens. One line around your provider client.
AI calls bill by token. A stuck loop, a runaway agent, or one abusive customer can burn hundreds of dollars before anyone looks at a graph. Most tools show you the damage after it lands. Bursora checks the budget before the call goes out and blocks it if it would blow a limit. Traffic light, not speed camera.
This package is the wrap. No proxy, no gateway; your app still talks straight to OpenAI, Anthropic, or Google. Bursora just gets a yes/no first, then the real token cost after.
Install
npm i @bursora/sdkBring your own provider client (openai, @anthropic-ai/sdk, @google/genai, ...). The SDK detects them by shape, so it never bundles them.
30 seconds
import OpenAI from "openai";
import { BudgetExceededError, withTags, wrap } from "@bursora/sdk";
const openai = wrap(new OpenAI(), {
apiKey: process.env.BURSORA_API_KEY!,
endpoint: process.env.BURSORA_ENDPOINT!,
});
await withTags({ tenant_id: "acme", agent_id: "support-bot" }, async () => {
try {
await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "hi" }],
});
} catch (e) {
if (e instanceof BudgetExceededError) {
// over budget: downgrade the model, queue it, show a fallback
} else throw e;
}
});Tag each call with who it's for (customer, agent, workflow). That's how spend gets grouped in the dashboard and how budgets know what to scope to.
What you get
- Block before spend. Over a hard limit?
BudgetExceededErrorthrows before the provider is ever called. No charge. - Soft limits. Notify and throttle modes let the call through and report after.
- Fail open. Can't reach Bursora? Your call still goes out. We don't become your outage.
- Streaming-safe. Chunks pass through untouched; usage is read off the final one.
- Decisions cache for 60 seconds; usage flushes after each call.
More providers
OpenAI, Anthropic, and Google Gemini all wrap exactly like the example above; detection is by client shape. Bedrock has its own wrapBedrock. And on the Vercel AI SDK (ai) you use bursoraMiddleware with wrapLanguageModel instead of wrap, since generateText never constructs a client for wrap to see.
Pick yours and copy the snippet:
- OpenAI · Anthropic · Google
- Amazon Bedrock
- DeepSeek, Groq, xAI, Mistral and other OpenAI-compatible
- Vercel AI SDK
Tags, batch metering, sharing one core across clients, budget snapshots, error handling: it's all in the docs. Start at bursora.com/docs/sdk/install.
API key
Sign in at bursora.com, create a workspace, grab your BURSORA_API_KEY.
License
MIT. © 2026 Vildan Bina.
