Backstop Documentation
In-process reliability layer for AI SDKs. Wrap your OpenAI and Anthropic Python clients with token budgets, circuit breaking, concurrency control, and an opt-in priced spend ledger.
Welcome to Backstop
Backstop is an in-process reliability layer for AI SDKs. It wraps your existing OpenAI and Anthropic Python clients with token budgets, circuit breaking, and concurrency control — all without routing prompts through third-party servers.
Prefer to watch first? The 132-second walkthrough covers
the whole product end to end: the problem, the one wrap() call, a live
dashboard watching a budget drain, the guardrail firing, per-agent ceilings, the
spend ledger, and reconciling that ledger against a provider statement. Every
frame is the product running — the dashboard shots are captures of
backstop dashboard --demo as a real workload drains a real budget, and the
terminal shots are verbatim output of the real commands.
It also produces, opt-in, a durable, priced, attributed spend ledger that a finance team can charge back. See What The Ledger Is for why that lives in an enforcement library, and Export a Chargeback for the recipe.
Version status. 0.6.0 is published — on PyPI as
backstop-ai, on npm asbackstop-ai, and as thev0.6.0GitHub Release — and the project is MIT licensed. The default branch carries unreleased work past that tag, including the spend ledger, sopip install -e ".[anthropic]"tracksmainrather than the release.The npm package of the same name is a partial TypeScript port, not the Python distribution: OpenAI only, it patches the client rather than injecting a transport, it has five priorities against Python's three, and it has no metrics, OpenTelemetry, Redis, hierarchical budgets, audit sinks or ledger. Use the Python package for the full feature set or for Anthropic.
Get started
- Quickstart → — get a working budget guardrail in 60 seconds
- Install Backstop → — all installation methods
- Using Budgets → — step-by-step budget tutorial
Learn how it works
- Architecture → — request flow, local mode, shared state
- How Budgets Work → — token estimation and reconciliation
- Circuit Breaking → — preventing cascading failures
- AIMD Congestion Control → — adaptive concurrency under pressure
- Caching Strategy → — response caching to reduce spend
- Benchmark Methodology → — how we measure overhead
- What The Ledger Is → — why an enforcement library writes a spend ledger
- Threat Model → — security posture and risk mitigations
Guides & references
- Export a Chargeback → — turn the ledger into a finance-grade CSV
- Dashboard Guide → — running the built-in operations dashboard
- Shared Budgets → — Redis-backed budgets across replicas
- Configure Retries → — retry policies and circuit breaker tuning
- CLI Reference — every
backstopandwedgecommand - Ledger Schema — the
SpendEventfields and the attribution dimensions - Configuration Reference — full
BackstopConfigAPI - Exceptions Reference — error hierarchy
- SDK Compatibility Matrix — tested SDK versions
- Concurrency & Scale Limits — GIL, threading, and multi-process guidance
- Benchmark Results — latest committed snapshot
— Suggest an edit on GitHub