$0.50 per pipeline run: the hard cap for CI agents
01 / $0.50 per pipeline run is a ceiling you can actually enforce
A coding agent in CI is not a fixed-price tool. It is a loop: it reads code, writes code, runs the tests, reads the output, and repeats until it believes the job is done or until something stops it. Every read and write is billed. CheapRelay prices per real token with no monthly fee and no subscription, so the cost of a run is whatever the loop consumed, including cache reads and cache writes. That is friendly to a tiny budget when the loop is short, and dangerous to a tiny budget when the loop is not. One agent that keeps re-reading a large repository can burn an entire week's allowance while you sleep. The fix is not a cleverer prompt. The fix is a number written into the repository that the pipeline refuses to cross. Start with $0.50 per pipeline run. That is enough for a small agent to finish a real task, and small enough that a runaway loop costs you less than a coffee.
Write that number down in one place first: a single file or environment block that every job reads. If the cap lives in three different workflow files, it will drift, and the file that drifted will be the one that bills you.
02 / Turn the dollar cap into a token ceiling before you write a step
A dollar limit is only enforceable once you convert it into tokens. Look up the current per-token rates for the model you intend to use on the CheapRelay pricing page and do the arithmetic once, by hand. If a run may spend $0.50, and your input rate is R dollars per million tokens while your output rate is W dollars per million tokens, you do not get one ceiling, you get two: a maximum input budget and a maximum output budget. Output normally costs more per token than input, so an agent that writes long explanations between edits drains the output side first. Cache reads and cache writes both count toward the bill, and cache writes are commonly the most expensive token class, so a huge system prompt that is re-sent and re-cached on every turn is the classic way to spend money without doing work.
For a $0.50 run, reasonable starting limits for a beginner look like this:
- ■ 150,000 to 250,000 total tokens across the whole run
- ■ output capped at 5 to 10 percent of that total
- ■ 10 to 20 agent turns maximum, counted in the wrapper
- ■ shared system prompt and tool descriptions kept under 10,000 tokens
- ■ each retry counted as a fresh run against the same $0.50, never as free rework
These are planning numbers, not measured benchmarks. The point is that they are small enough to fail safely and large enough to finish a scoped task like fixing one failing test or tightening one function.
03 / Wrap the agent loop with hard stops the job cannot argue with
The agents you run in CI, including Claude Code, Codex and Gemini CLI, all expose some combination of a maximum output token setting and a turn or step limit. Set both. Do not rely on the agent choosing to stop, because stopping early is exactly the behaviour a helpful agent is least likely to adopt.
Then put a thin wrapper script around the agent. It does not need to be clever:
- ■ read the budget, the token ceilings and the turn limit from environment variables
- ■ run one agent turn at a time rather than launching an open-ended session
- ■ after each turn, record the reported token usage and add it to a running total
- ■ stop the run as soon as the total reaches the ceiling, even if the task is unfinished
- ■ exit with a distinct status code so the workflow can report a spend stop rather than a test failure
- ■ print the final tally at the end so the log line is the receipt
A spend stop is a normal outcome, not an error to hide. A half-finished fix that cost $0.48 and told you exactly where it stopped is far more useful than a finished fix that cost $4.80 on a night when you had $5 in the account.
04 / Estimate the run before it starts and fail cheap
Most overspend in CI comes from runs that should never have launched. Add a pre-flight step that estimates the run and refuses to start when the estimate exceeds the cap. The estimate does not need to be precise. Count the characters in the files the agent will see, the diff, and the issue text, divide by four as a rough token floor, then multiply by the number of turns you allow. If the result is above your ceiling, shrink the task or split it across runs instead of raising the budget.
- ■ scope the agent to a directory or a file list instead of the whole repository
- ■ pass a short, written task description instead of an open-ended instruction
- ■ keep generated reports and test output out of the context unless they are needed
- ■ skip scheduled agent jobs entirely when the branch has no relevant changes
Set the budget per job rather than per workflow. A workflow with three jobs and one shared budget will always be spent by the first job, and the other two will either run over cap or run on nothing.
05 / Route routine runs to a cheap model and escalate only with evidence
The cheapest dollar is the one you never spend, so pick the smallest model that can do the job. On a relay you can change models with one string, which makes tiering practical even on a tiny budget. Routine work such as fixing a lint error, renaming a symbol, or repairing a test fixture can go to a low-cost model such as DeepSeek V4 Flash. When a task is genuinely harder, start with a mid-tier option such as Gemini 2.5 Flash and promote it to a larger model only if the first attempt stayed under half the budget and did not finish. That single rule, escalate only after a cheap attempt, is worth more than any prompt trick.
Keep the receipts. Print the model, the token counts, the cache read and write counts, and the estimated spend in every run summary. Over a month those lines tell you which workflow is expensive and why, which is the only way to cut cost without guessing.
06 / Read the weekly ledger and cut whatever repeats
Once a week, take five minutes with the per-run numbers and ask three questions. Which workflow spent the most? Which runs stopped early at the cap and therefore need a larger scope rather than a larger budget? Which prompts were re-sent and re-cached on every turn? Fix the third one first, because prompt bloat is pure cost. Then fix the second by splitting tasks. Only then consider raising the $0.50 ceiling, and raise it in steps of a quarter rather than doubling it.
CheapRelay exists for exactly this kind of metered work: one key reaches a wide range of models, it works with OpenAI-compatible tooling under /v1 and with Gemini-native routes under /v1beta, and billing is per real token with no monthly fee, so a run that costs twelve cents bills twelve cents. If you want to try the setup above, sign up at CheapRelay and run your first capped pipeline with a budget you would not mind losing. There is also a 20 percent reward on what invited users pay, which is a small but real offset once your team starts running agents daily.
Set the cap, wrap the loop, print the receipt. Do those three things before you add anything clever, and your coding agent becomes a predictable line item instead of a monthly surprise.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-30 | Coding agents, cheaply | EN | One Claude Code fix: $18.40 first, $2.13 second Two Claude Code receipts judged on price per useful result, plus the two environment variables that changed the bill. |
| 2026-10-30 | Coding agents, cheaply | EN | Running Claude Code on $4.10 a Day Instead of $38 Two daily receipts, the same coding work, and a price-per-useful-result verdict. Real token math, no subscriptions. |
| 2026-10-30 | Coding agents, cheaply | EN | The $50 Coding Bill: 6 Habits That Quietly Double It Six coding assistant habits that quietly double an AI bill, and a $5-a-month workflow that keeps token costs honest. |
| 2026-10-30 | Coding agents, cheaply | EN | One $5 Receipt Covers Claude, Codex and Gemini CLI A beginner walkthrough for running Claude Code, Codex and Gemini CLI on one cheap relay key, with a $5 first-month cap and honest token math. |
| 2026-10-30 | Coding agents, cheaply | EN | Claude Code on Windows: $0 Setup and a $10 First Receipt Set up Claude Code on Windows with PowerShell environment variables, then meter every token with CheapRelay pay-as-you-go billing. |
| 2026-10-30 | Coding agents, cheaply | EN | My $0.40 Receipt After Pairing Cheap First A beginner walkthrough: pair with a cheap model first, escalate only when stuck, and keep an evening receipt at $0.40. |