---
title: "Cut coding agent LLM costs - 10 tactics with savings"
description: "Ten concrete ways to lower what Cline, Aider, opencode or your own coding agent spends on tokens, each with the math behind the saving and how to measure it."
url: https://broadrouter.com/blog/cut-coding-agent-llm-costs/
lang: en
updated: 2026-11-14
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# 10 ways to cut coding agent LLM costs, with estimated savings

By the BroadNet Inference team · 6 min read · Published 2026-11-14

Most spend is input resent every turn. Keep the prompt prefix stable so it caches, name files, trim tool output, lower reasoning effort, cap loops and retries, and route easy steps to cheaper models. On DeepSeek V4.1 Flash, cached input costs about 3% of new input. Past about 917 million input tokens a month, a $60 flat plan is cheaper.

## Key takeaways

-   Input dominates coding agent bills because the agent resends context on every turn, so caching is usually the biggest lever.
-   Raising the cache share from 50% to 80% cuts the input bill on DeepSeek V4.1 Flash by more than half.
-   Trimming tool output and naming files up front cuts the tokens resent on every later turn.
-   Step caps, retry caps and lower reasoning effort stop the costs that have no natural ceiling.
-   A full-time agent costs $65.40 a month per token in BroadNet's example; a Full Moon plan is $60.

**On this page**

1.  Where does a coding agent’s money go?
2.  Which tactics save the most?
3.  1\. Keep the prompt prefix stable so it is cached
4.  2\. Tell the agent which files matter
5.  3\. Trim tool output before it enters the context
6.  4\. Lower reasoning effort on routine steps
7.  5\. Cap steps per task
8.  6\. Cap and log retries
9.  7\. Start a fresh session for each task
10.  8\. Route easy steps to a cheaper model
11.  9\. Summarise rarely, and append the rest
12.  10\. Switch to a flat plan once you pass break-even
13.  How do you measure whether a tactic worked?
14.  Where BroadNet Inference fits

A coding agent’s bill grows in a way chat bills don’t. Every turn resends the system prompt, the tool list, the files it has read and the conversation so far. By turn 30, one request can carry hundreds of thousands of input tokens, most of them repeats. The ten tactics below target where those tokens go. Each has an estimated saving with the math shown, using BroadNet Inference prices synced 2026-11-14. Your numbers will differ, so measure before and after.

## Where does a coding agent’s money go?

Three meters, in order of size for most agents:

1.  **Input**, resent every turn. Mostly cacheable.
2.  **Output**, including [reasoning tokens](https://broadrouter.com/glossary/reasoning-tokens/) you never see.
3.  **Waste**: retries, loops that make no progress, and context nobody needed.

Read `prompt_tokens`, `prompt_tokens_details.cached_tokens` and `completion_tokens` for a day of real work before changing anything. [Where an agent loop’s tokens go](https://broadrouter.com/blog/agent-token-budget/) shows how to break them down.

## Which tactics save the most?

| # | Tactic | What it cuts | Estimated saving |
| --- | --- | --- | --- |
| 1 | Keep the prompt prefix stable | New input | Input bill down by half or more |
| 2 | Name files instead of letting the agent search | Exploration turns | Fewer turns, fewer resends |
| 3 | Trim tool output | Input on every later turn | Scales with log size |
| 4 | Lower reasoning effort on routine steps | Hidden output | Depends on task mix |
| 5 | Cap steps per task | Runaway loops | Puts a ceiling on the worst case |
| 6 | Cap and log retries | Duplicate requests | Each avoided retry is a full request |
| 7 | Start a fresh session per task | Stale history | Shorter context per turn |
| 8 | Route easy steps to a cheaper model | Price per token | Large on routed steps |
| 9 | Summarise rarely, append often | Cache misses | Keeps tactic 1 working |
| 10 | Switch to a flat plan past break-even | The token meter | $5.40 a month in our example |

## 1\. Keep the prompt prefix stable so it is cached

[Cached input](https://broadrouter.com/glossary/cached-input-tokens/) on DeepSeek V4.1 Flash costs $0.0055 per 1M; new input costs $0.175, about 32 times more. Order prompts as system prompt, tools, files, history, new message. Never put a timestamp at the top. Cursor reported in September 2026 that harness changes, including a system prompt about two-thirds shorter and tools loaded only when needed, cut users’ token costs by 7%. [How to structure prompts so the prefix caches](https://broadrouter.com/blog/prompt-structure-for-caching/).

**Estimated saving.** Take 1,000M input tokens a month. At 50% cache hits you pay new-input price on 500M; at 80% you pay it on 200M. Including the cached part, the input bill falls by about 56%. [How to raise your cache rate](https://broadrouter.com/blog/cached-input-tokens-explained/), or try your own numbers in the [prompt caching calculator](https://broadrouter.com/tools/prompt-caching-calculator/).

## 2\. Tell the agent which files matter

A vague task (“fix the login bug”) sends the agent searching: listing directories, opening files, reading them into context. Each file it opens is then resent on every later turn. Name the files and the expected change. Keep a short project map in the repository that the agent reads first.

**Estimated saving.** If a 40,000-token file is read on turn 3 of a 30-turn task, it is resent about 27 times: over a million input tokens for one file. Not reading it saves all of that.

## 3\. Trim tool output before it enters the context

Test runners, build logs and `git diff` can return tens of thousands of tokens. Show the agent the last 100 lines of a log or only the failing tests. Most agent tools let you set an output limit for commands.

**Estimated saving.** Same math as tactic 2: every token you trim is saved once per remaining turn.

## 4\. Lower reasoning effort on routine steps

DeepSeek V4.1 Flash and GLM 5.3 think before they answer, and the thinking is billed as output. Set `reasoning_effort: "low"` for renames, formatting and small edits. Keep `max_tokens` high enough to finish, or you pay for thinking and get an empty reply. [Reasoning token costs](https://broadrouter.com/blog/reasoning-tokens-cost/).

**Estimated saving.** Measure `completion_tokens_details.reasoning_tokens` before and after on the same 20 tasks. The saving is the drop times the output price ($0.52 per 1M).

## 5\. Cap steps per task

An agent that cannot fix a test can loop for 100 turns, each one larger than the last. Set a maximum number of turns per task, and stop when the same tool call repeats three times. A step cap turns an unbounded cost into a bounded one.

## 6\. Cap and log retries

A retried request is a new inference, billed again on a per-token key. Retry 429 and 5xx with backoff and a fixed limit; do not retry other 4xx errors such as 400 or 422. [Errors and retries](https://broadrouter.com/guides/errors-and-retries/).

## 7\. Start a fresh session for each task

History from the last task is dead weight on the next one. A new session per task keeps the context small. This does not conflict with caching: the system prompt and tools still form a shared, cacheable prefix.

## 8\. Route easy steps to a cheaper model

Not every step needs the same model. Commit messages, changelog lines and simple classification can go to [Gemma 4 VL 26B](https://broadrouter.com/models/gemma-4-vl-26b/) at $0.10 input and $0.22 output per 1M. If you use [GLM 5.3](https://broadrouter.com/models/glm-5.3/) for tool-heavy steps, route the rest to DeepSeek V4.1 Flash: GLM 5.3’s output costs about 6.7 times more. [GLM 5.3 vs DeepSeek V4.1 Flash](https://broadrouter.com/blog/glm-5-3-vs-deepseek-v4-1-flash/).

**Caution.** Measure cost per finished task. A cheaper model that needs twice the turns can cost more.

## 9\. Summarise rarely, and append the rest

When an agent compresses its history, it rewrites the prompt and the cache starts over. Summarise only when the context is close to its limit, in one large step, then append again. This keeps tactic 1 working.

## 10\. Switch to a flat plan once you pass break-even

Per-token billing rewards small usage. A full-time agent is not small. In BroadNet’s worked example, a full-time coding agent (1,000M input at 80% cache, 50M output) costs $65.40 a month per token; an always-on agent costs $196.20. A Full Moon session is $60 a month with no token meter, one request at a time. At that point tactics 1 to 9 still save time, but no longer money. Check your own volumes with the [flat-rate vs per-token calculator](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/), or read [the break-even math](https://broadrouter.com/blog/flat-rate-vs-pay-per-token-llm-api/) and [running parallel agents on a flat rate](https://broadrouter.com/blog/run-parallel-coding-agents-flat-rate/).

## How do you measure whether a tactic worked?

1.  Pick 20 representative tasks from your backlog.
2.  Run them with your current setup and log tokens per task.
3.  Apply one tactic at a time and rerun.
4.  Compare cost per finished task, not cost per request.

For apps that are not coding agents, the same levers in a general order are in [how to reduce LLM API costs](https://broadrouter.com/blog/how-to-reduce-llm-api-costs/).

Setup guides for common agents: [Aider](https://broadrouter.com/guides/aider-unlimited-deepseek/), [Cline](https://broadrouter.com/guides/cline-openai-compatible/), [Zoo Code, the fork of the now shut-down Roo Code](https://broadrouter.com/guides/roo-code-openai-compatible/) and [OpenCode](https://broadrouter.com/guides/opencode-custom-provider/).

## Where BroadNet Inference fits

BroadNet gives coding agents a cheap cached-input rate on DeepSeek V4.1 Flash and, for heavy use, unlimited sessions from $60 a month, on an OpenAI-compatible endpoint that these agents already support. It does not run closed frontier models, so if your agent needs one for its hardest steps, keep that model on its own vendor and send the bulk of turns here. [See the plans](https://inference.broadnet.ai/plans?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-cut-coding-agent-llm-costs&utm_content=body).

Free tools for this

-   [LLM API cost calculator](https://broadrouter.com/tools/llm-api-cost-calculator/) Price a workload on every model at once, with cache hits, reasoning and a flat-plan check.
-   [Flat-rate vs per-token LLM cost calculator](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/) Break-even between an unlimited plan and paying per token, per agent.
-   [Prompt caching savings calculator](https://broadrouter.com/tools/prompt-caching-calculator/) Bill with and without caching, by prefix share and hit rate.
-   [Prompt token diff](https://broadrouter.com/tools/prompt-token-diff/) Two prompt versions side by side: changed lines, exact token delta and the monthly cost difference.

[All free tools](https://broadrouter.com/tools/)

## Terms in this article

[Token](https://broadrouter.com/glossary/token/)

A token is the unit of text a language model reads and writes: a word, part of a word, a punctuation mark or a byte sequence produced by the model's tokenizer. LLM APIs count, limit and usually bill usage in tokens.

[Tool calling](https://broadrouter.com/glossary/tool-calling/)

Tool calling, also called function calling, is an LLM API feature in which the model returns a structured request to run a function the developer has defined, with JSON arguments. The application runs the function and sends the result back; the model never runs code itself.

[AI coding agent](https://broadrouter.com/glossary/coding-agent/)

An AI coding agent is a software tool in which a language model works on a codebase in a loop: it reads files, edits them, runs commands such as tests, reads the output and decides the next step until the task is done or a limit is reached.

[System prompt](https://broadrouter.com/glossary/system-prompt/)

A system prompt is the instruction text an application sends to a language model ahead of the conversation, usually as a message with the system or developer role. It sets the model's role, rules, tone and output format, and the model is meant to follow it over conflicting user messages.

[Input and output tokens](https://broadrouter.com/glossary/input-and-output-tokens/)

Input tokens are the tokens a language model reads in a request, including the system prompt, conversation history, tool definitions and images. Output tokens are the tokens it generates in reply, including any reasoning. LLM APIs usually price them separately, and output usually costs more.

[Reasoning tokens](https://broadrouter.com/glossary/reasoning-tokens/)

Reasoning tokens are tokens a reasoning model generates to work through a problem before it writes its visible answer. They are usually billed as output tokens, count toward the output limit and the context window, and may be hidden or summarized by the API.

[Cached input tokens](https://broadrouter.com/glossary/cached-input-tokens/)

Cached input tokens are prompt tokens that an LLM provider has recently processed and can reuse from a cache instead of computing again, usually a repeated prefix such as a system prompt or document. Providers bill them at a lower rate than new input tokens.

[Pay-as-you-go](https://broadrouter.com/glossary/pay-as-you-go/)

Pay-as-you-go is a pricing model in which you pay only for what you use, metered per unit such as tokens, requests or audio minutes, with no subscription or minimum commitment. Most LLM APIs bill this way, from a prepaid balance or a periodic invoice.

## Questions

### Why are coding agents so expensive to run?

They resend the system prompt, tool definitions, file contents and history on every turn, so input tokens grow with each step. Reasoning adds hidden output on top.

### What is the single biggest way to cut coding agent costs?

Keep the start of the prompt identical between turns so it is billed as cached input. On DeepSeek V4.1 Flash cached input costs $0.0055 per 1M against $0.175.

### Is a cheaper model always cheaper for a coding agent?

No. A weaker model that takes more steps, or fails and retries, can cost more in total. Measure cost per finished task, not per token.

### When is a flat-rate plan cheaper for a coding agent?

For DeepSeek V4.1 Flash, at about 917 million input and 46 million output tokens a month with 80% cache hits. A full-time agent usually crosses that.

### How do I stop a coding agent from looping and burning tokens?

Cap the number of turns per task, stop when the same tool call repeats three times, and cap retries on 429 and 5xx errors. A step cap turns an unbounded cost into a bounded one.

## Keep reading

-   [Claude Code with open models: proxies, native endpoints and limits](https://broadrouter.com/blog/claude-code-with-openai-compatible-models/)
-   [Cached input tokens: how to cut an LLM API bill](https://broadrouter.com/blog/cached-input-tokens-explained/)
-   [Reasoning tokens: why you pay for more output than you see](https://broadrouter.com/blog/reasoning-tokens-cost/)
-   [Flat-rate vs pay-per-token LLM API: the break-even math](https://broadrouter.com/blog/flat-rate-vs-pay-per-token-llm-api/)
-   [How to run parallel coding agents on a flat-rate LLM API](https://broadrouter.com/blog/run-parallel-coding-agents-flat-rate/)
-   [LLM API spend control: budgets, key limits and loop protection](https://broadrouter.com/blog/llm-api-spend-control/)
-   [LLM API price changes in October 2026: 3 rises, no cuts](https://broadrouter.com/blog/llm-api-price-changes-october-2026/)
-   [Do LLM API prices only go down? 52 rises and how to budget for them](https://broadrouter.com/blog/llm-api-price-increases/)
-   [Guide: Run Aider on unlimited DeepSeek V4.1 Flash](https://broadrouter.com/guides/aider-unlimited-deepseek/)
-   [Guide: Use Cline with BroadNet Inference (OpenAI Compatible provider)](https://broadrouter.com/guides/cline-openai-compatible/)
-   [Guide: Use Roo Code with BroadNet Inference (OpenAI Compatible)](https://broadrouter.com/guides/roo-code-openai-compatible/)
-   [Guide: Add BroadNet Inference to opencode as a custom provider](https://broadrouter.com/guides/opencode-custom-provider/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-cut-coding-agent-llm-costs&utm_content=page-cta) ·

**Sources**

-   [BroadNet Inference machine-readable prices (pricing.json, fetched 2026-11-14)](https://inference.broadnet.ai/pricing.json?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-cut-coding-agent-llm-costs&utm_content=sources)
-   [BroadNet Inference plans and plan FAQ (fetched 2026-11-14)](https://inference.broadnet.ai/plans?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-cut-coding-agent-llm-costs&utm_content=sources)
-   [BroadNet Inference API reference, reasoning and cached tokens (fetched 2026-11-14)](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-cut-coding-agent-llm-costs&utm_content=sources)
-   [Cursor, improved token efficiency (September 23, 2026; fetched 2026-11-14)](https://cursor.com/blog/improved-token-efficiency)
