A $5 Agent Budget Can Leak Before First Task
01 / The first hidden cost is usually repeated context
A beginner often estimates an agent task from the prompt they typed: 2,000 tokens in, 1,000 tokens out, and a small bill. Agent frameworks rarely work that way. They may send the conversation again on every planning step, include tool results, attach system instructions, and ask the model to review its own work.
A five-step task can therefore create five separate requests. If each request carries 20,000 tokens of accumulated context, the framework processes about 100,000 input tokens before counting output. The visible answer may be short, but the bill follows the requests, not the final paragraph.
02 / Tool output can quietly become the largest payload
File listings, logs, web pages, database rows, test failures, and shell output all become context once an agent reads them. A command that prints 5,000 lines may be cheap on your laptop and expensive in an API workflow. The same is true of dumping an entire repository when the agent needs only three files.
Set output limits on tools where possible. Ask commands for summaries, restrict searches to relevant directories, and avoid sending generated files back into the conversation. A useful beginner rule is to inspect the size of every tool result before allowing the agent to continue.
03 / Retries and loops multiply a small mistake
Most frameworks retry failed requests. Some also retry when the model returns an incomplete tool call, invalid JSON, or an answer that fails a validation step. One bad instruction can turn one intended request into three or ten billable requests.
During development, use a maximum step count and a maximum retry count. Log the request number, model name, input tokens, output tokens, and error reason. Stop the run when it reaches a fixed token ceiling. A five-dollar spending target is only useful when the application can actually stop before the ceiling is exceeded.
04 / Cache billing is still billing
Prompt caching can reduce repeated processing costs, but it does not mean cached traffic is free. CheapRelay bills per real token, including cache reads and cache writes. That distinction matters for agents because a stable system prompt or large project context may be written once and read many times.
Track three numbers separately: ordinary input tokens, cache-write tokens, and cache-read tokens. Compare them with output tokens. If your framework rebuilds a slightly different prompt on every turn, it may miss the cache and repeatedly write large blocks instead of reusing them.
05 / Choose a small model for the control work
Do not use the most capable model for every step. Planning, file classification, formatting, and simple checks can often use a lower-priced option, while a difficult coding decision can be escalated. For example, you might route routine calls to Gemini 2.5 Flash and reserve Claude Haiku 4.5 for tasks that need stronger reasoning. Check current prices before choosing; the important point is to assign models by job, not by habit.
06 / A practical $5 test plan for your first agent
- ■ Start with one narrow task, such as changing one function and running one test.
- ■ Allow no more than 6 agent steps and 2 retries.
- ■ Cap tool output by lines, bytes, or returned rows.
- ■ Record input, output, cache-read, and cache-write tokens for every request.
- ■ Stop the run locally when your chosen token budget is reached.
- ■ Review the receipt before increasing the step limit.
For a tiny-budget first run, sign up for CheapRelay and connect the API base to your existing OpenAI-compatible client at https://api.cheapapirelay.com/v1. There is no monthly fee or subscription, and one key can reach multiple providers. You pay for actual usage, so your framework’s request behavior remains the main variable to control.
07 / The cheapest agent is the one that stops
Price comparison helps, but request design usually comes first. Keep context narrow, limit tool output, cap retries, separate easy work from hard work, and inspect cache activity. Once those controls are in place, a small budget becomes a measurable engineering constraint instead of a hopeful estimate.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-29 | Spend less | EN | JSON Output on a $1 Test Budget A beginner walkthrough for testing JSON mode and structured output with small prompts, local validation, and a firm spending limit. |
| 2026-10-29 | Spend less | EN | $0.02 instead of $0.12 in repeated chat history A tiny-budget walkthrough for replacing old chat messages with a compact summary, estimating the cost and keeping important details. |
| 2026-10-29 | Spend less | EN | ¥1 Translation Budget: Rank by Usable Output Build a translation ranking on a ¥1 budget using actual charges, accepted text, and retry costs instead of unsupported model leaderboards. |
| 2026-10-29 | Spend less | EN | 10,000 rows, 200 AI checks, no monthly fee Clean spreadsheet data on a tiny budget: fix predictable errors locally, batch ambiguous labels, and measure token costs before scaling. |
| 2026-10-29 | Spend less | EN | Spend $0 to Count Claude Input Tokens Use Anthropic’s count_tokens endpoint to estimate prompt size before a paid request, with a small-budget walkthrough and limits to watch. |
| 2026-10-29 | Spend less | EN | Spend $0 First on Your Embedding Pipeline A tiny-budget guide to chunking, retrieval, caching, and measuring costs before paying for embeddings or larger models. |