Skip to main content

Burnmap

Budget enforcement for LLM agents. One line of code, no proxy, hard-stop before costs spiral.

Install

pip install burnmap
# with SDK support
pip install "burnmap[anthropic]"
pip install "burnmap[openai]"
pip install "burnmap[all]"

Quickstart

import burnmap

with burnmap.run("auth-refactor", budget=2.00) as r:
    response = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=1024,
        messages=[{"role": "user", "content": "Refactor the auth module"}],
    )

print(r.report.summary())
# Run 'auth-refactor' completed in 1.23s. 1 call(s), $0.0842 of $2.00 budget...

If spend hits the budget limit, BudgetExceededError is raised before the next call executes:

from burnmap import BudgetExceededError

try:
    with burnmap.run("agent-loop", budget=0.50) as r:
        while True:
            client.messages.create(...)   # raises BudgetExceededError at the limit
except BudgetExceededError as e:
    print(f"Stopped at ${e.spent_so_far:.4f} after {e.call_count} calls")

Per-user budget enforcement for multi-tenant products:

with burnmap.run("summarise", budget=0.10, user_id="usr_123"):
    client.messages.create(...)

CLI — wrap any agent command

burnmap wrap --budget 5.00 --job "auth-refactor" -- claude --dangerously-skip-permissions "refactor auth"
burnmap wrap --budget 10.00 -- python my_agent.py

Burnmap scans the subprocess output for API usage JSON, accumulates cost in real time, and kills the process if spend exceeds --budget. Prints a cost summary on exit.

What it does

  • Hard-stop budget enforcement — raises BudgetExceededError before the call that would push spend over the limit.
  • Run-level attribution — groups all LLM calls inside one with block, tracks cost per run rather than per API call.
  • Per-call breakdown — r.report.cost_by_call shows each call's model, tokens, cost, and running total.
  • Loop detection — kills runaway agents that are hammering the API or accumulating context geometrically.
  • Async-native — works with async with and is safe across asyncio.gather and asyncio.create_task.

What it doesn't do

  • No proxy. API calls go directly from your code to Anthropic/OpenAI. No latency added, no single point of failure, API keys stay local.
  • No dashboard (yet). Cost data lives in r.report — export it however you like.
  • Does not intercept calls made outside a burnmap.run() block.

License

MIT — see LICENSE.

Metadata

Release files for burnmap 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for burnmap 0.2.0
File Size Uploaded Provenance Actions
burnmap-0.2.0.tar.gz 20.6 kB Without provenance Details for burnmap-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for burnmap 0.2.0
File Interpreter ABI Platform Actions
burnmap-0.2.0-py3-none-any.whl Python 3 none any Details for burnmap-0.2.0-py3-none-any.whl

Total release size: 36.0 kB

Release files / burnmap-0.2.0.tar.gz

Download URL burnmap-0.2.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
13d8b6c0b7a1f75546875a1b77e3bcbd39cbce5b06a3c956418b17840b81b332
BLAKE2b-256 checksum
How to use checksums
39dbe6d69392f7cb3a80e485980b4564a6417f03df263c7196384e2633fa59df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / burnmap-0.2.0-py3-none-any.whl

Download URL burnmap-0.2.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71f526031236d9660f4e594b23d9db8bbccf29f46f70c7b714c8a4016ad08a2c
BLAKE2b-256 checksum
How to use checksums
4348584381bde392fd5053fef7a97a4865c353b2c16b0c792901a652dd8d0f50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for burnmap 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page