Per-call vs per-key caps: picking the right spend guard for AI agents
Overall_Note4346 · reddit · 2026-10-30
The author breaks down two spend-control patterns for agents:
- Per-call caps: a check in your own code refusing calls above a set price, best for scripted jobs (implemented as a wrapper around the OpenAI SDK).
- Per-key caps: limits live on the key (hourly/daily/lifetime/per-tool), each bounded call reserves its max cost before running—better when the agent picks its own steps.
Rule of thumb: if you write the calls, cap per call; if the agent writes them, cap the key. Most of the author's agent-driven work in Cursor and Claude Code sits on capped keys.
More from coding & agent
- Cursor pulls plugin marketplace after malicious Claude Code extension hits up to 5,000 users — EricBuess · 2026-10-30
- Autonomous agents debated his sleep rule overnight, then called him at 7am to save a release — airesearch12 · 2026-10-30
- Dev's slangy commit message 'api key ui very nice' becomes a self-own screenshot — itsOmSarraf_ · 2026-10-30
- lattedit: a local-first browser LaTeX editor with a JSON API for AI agents — cneuralnetwork · 2026-10-30
- Pedro Domingos: COBOL will outlive Claude Code — pmddomingos · 2026-10-30
- Anthropic's Felix Rieseberg: 4 ways to use AI more ambitiously — speed, altitude, depth, range — FinanceYF5 · 2026-10-30