# shekel

A Python library that enforces spend limits on AI agents by monkey-patching LLM provider calls, stopping runs, warning, or downgrading models before a budget is exceeded.

shekel is a Python library for controlling AI agent spend. It wraps a `budget` context manager around agent code and monkey-patches the OpenAI, Anthropic, and other provider clients for the duration of the run, so no code changes to the agent itself are required.

It supports a hard cap that raises an error once spend crosses the limit, a configurable warning threshold, automatic fallback to a cheaper model near the limit, and a tracking-only mode. Framework integrations auto-patch LangChain, LangGraph, CrewAI, AutoGen, the OpenAI Agents SDK, and MCP, with optional per-agent budgets in AutoGen and the OpenAI Agents SDK.

It installs via pip with optional extras for OpenAI, Anthropic, or all supported providers, and ships a `shekel run` command that enforces a budget on an existing script without editing it.

Website: https://github.com/arieradle/shekel
