If you've ever tried to figure out which of your AI agents is responsible for that shocking API bill at the end of the month, you know the pain. OpenAI and Anthropic give you usage totals—fine-grained attribution? Forget about it. That's exactly the problem spaturzu tackles with a new set of open-source SDKs that let you meter, attribute, and budget-cap LLM calls per agent without touching your existing code.
The Core Problem: Invisible Agent Spend
Most production AI systems run multiple agents in parallel—a support triage bot, a research pipeline, a synthesize step—and they all share the same API keys. When the bill hits, you're looking at one number with zero visibility into which autonomous process made it rain tokens. spaturzu solves this by wrapping your existing provider clients (OpenAI, Anthropic, Bedrock, Gemini, or Mistral) and automatically tagging every call with the agent that initiated it. The migration is absurdly simple: swap one import statement from import OpenAI from "openai" to import OpenAI from "@spaturzu/sdk/openai", and your construction and call sites stay exactly the same.
How Attribution Works in Practice
The library uses a run() context manager to wrap blocks of work under a named agent. Inside that block, every model call gets billed to that agent automatically—so your dashboard shows cost per agent instead of one lump sum. For nested workflows like a research pipeline feeding into synthesis, spaturzu creates a cost tree where parent and child agents share a run ID, letting you see exactly how spend propagates through multi-step chains. You can also tag calls globally by environment or team, then override per-frame with customer-specific tags. The tagging system lets you slice costs along any dimension: production vs staging, growth team vs platform team, individual customer accounts.
Hard-Cap Budgets and Cross-Provider Failover
Beyond metering, spaturzu includes two killer features for production reliability. First, hard-cap budgets that raise BudgetExceededError before the request ever reaches your provider—no tokens spent if an agent hits its limit. Second, cross-provider fallback chains that automatically retry on 429 or 5xx errors against a backup provider (say, Anthropic when OpenAI is having issues) and translate the response back to your primary provider's shape so your code never knows the difference. All 20 directional provider pairs are supported in v1, though streaming with tool use isn't there yet.
SDK Availability and License
spaturzu ships as @spaturzu/sdk on npm for TypeScript/Node (ESM-only) and spaturzu on PyPI for Python 3.10+. Provider clients are optional dependencies—install only the ones you actually call. There's also an experimental OpenClaw plugin (@spaturzu/openclaw) in the works, though it's explicitly marked as not production-ready. The project is MIT-licensed from Superchiu Ltd.
Key Takeaways
- One-import swap migration: change your provider import to spaturzu's wrapper and everything else stays the same
- Per-agent cost attribution with nested run() calls creates a full cost tree for complex workflows
- Hard-cap budgets prevent runaway agents by raising BudgetExceededError before tokens are spent
- Cross-provider fallback chains provide automatic resilience without code changes
- Supports OpenAI, Anthropic, Bedrock, Gemini, and Mistral in both TypeScript and Python
The Bottom Line
This is the kind of infrastructure tooling that should have existed two years ago when everyone started building agentic systems. Cost attribution isn't optional at scale—it's the difference between debugging a $50K surprise bill or catching runaway agents in real time. If you're running any production multi-agent system, spaturzu deserves a look before your next billing cycle.