Best Cheap LLM API for Agent Loops
Agent loops get priced off a per-million-token rate card, while the actual turn is 79% tool result and 3% answer, so the model that looks affordable is not the one that is.
📜 Table of Contents
A single agent turn, counted with a tokenizer rather than guessed: 52 tokens of system prompt, 245 tokens of tool schema for two tools, 26 tokens of user question, 1,232 tokens of tool result, 42 tokens of answer. That is 1,555 input tokens and 42 output. Run a thousand of those turns and the bill ranges from 3 cents to 5.30 dollars depending only on which model sits behind the loop.
The 210x spread is real, and the ranking is not the one most teams assume. Every price below comes from the OpenRouter models endpoint on 2026-11-24, in dollars per million tokens. The token profile comes from the same measurement harness used for the format comparison published today.
What a turn actually costs in tokens
| part of the turn | tokens | what it was |
|---|---|---|
| system prompt | 52 | a release-tracking assistant, four sentences and two rules |
| tool schema | 245 | two function definitions with descriptions and parameters |
| user question | 26 | one sentence |
| tool result | 1,232 | 12 repository records as compact JSON, 11 fields each |
| answer | 42 | a short table-free reply |
| total input | 1,555 | system, tools, question and result |
The tool result is 79 percent of the input. Any agent loop that returns lists or records lives or dies on that one block, which is why the format rules are worth more than the model choice at small scale. Switching that result from compact JSON to a comma-separated table drops the turn to 1,316 input tokens and cuts every cost below by 15 percent.
Eleven models, one turn, ranked by cost
Cost per 1,000 turns uses 1,555 input and 42 output tokens. The monthly column is 300,000 turns, roughly 10,000 turns a day for 30 days, at the short-answer profile.
| model (as listed) | in $/M | out $/M | context | per 1,000 turns | 300k turns |
|---|---|---|---|---|---|
| inclusionai/ling-3.0-tiny | 0.015 | 0.045 | 262,144 | $0.025 | $7.56 |
| meta-llama/llama-3.1-8b-instruct | 0.020 | 0.040 | 131,072 | $0.033 | $9.83 |
| mistralai/mistral-nemo | 0.029 | 0.030 | 131,072 | $0.046 | $13.91 |
| qwen/qwen3.7-flash | 0.030 | 0.130 | 1,000,000 | $0.052 | $15.63 |
| deepseek/deepseek-v4.1-flash-1017 | 0.030 | 0.200 | 1,048,576 | $0.055 | $16.51 |
| z-ai/glm-5.3-flash | 0.040 | 0.074 | 1,048,576 | $0.065 | $19.55 |
| openai/gpt-oss-120b | 0.050 | 0.250 | 131,072 | $0.088 | $26.47 |
| openai/gpt-5-nano | 0.050 | 0.400 | 400,000 | $0.095 | $28.36 |
| anthropic/claude-haiku-4.5 | 1.000 | 5.000 | 200,000 | $1.765 | $529.50 |
| openai/gpt-5.1 | 1.250 | 10.000 | 400,000 | $2.364 | $709.13 |
| anthropic/claude-sonnet-4.5 | 3.000 | 15.000 | 1,000,000 | $5.295 | $1,588.50 |
Fifteen more entries in the same endpoint list both prices as zero. That is a routing policy rather than a free lunch, it changes without notice, and none of them was measured here, so treat that list as a testing channel rather than a billing plan.
Where the 210x comes from
At 42 output tokens the input price decides almost everything: between 82 and 97 percent of each cost above is the 1,555 input tokens. A model with a cheap prompt price and an expensive completion price still lands low in this table, which is how qwen3.7-flash at 0.030 in and 0.130 out beats gpt-oss-120b at 0.050 and 0.250 despite a worse output rate.
Change the answer length and the ordering shifts. At 400 output tokens per turn the same eleven models cost $0.041, $0.047, $0.057, $0.099, $0.127, $0.092, $0.178, $0.238, $3.555, $5.944 and $10.665 per 1,000 turns, in the order listed above. glm-5.3-flash moves from sixth to fourth, deepseek-v4.1-flash from fifth to sixth, and claude-haiku-4.5 doubles from $1.765 to $3.555. The three cheapest hold their places because their input and output prices sit close together.
Batch variants cut the prices further and trade latency for it. In the same endpoint, glm-5.3-flash:batch lists 0.023 in and 0.068 out against 0.040 and 0.074; gpt-oss-120b:batch lists 0.0296 and 0.136 against 0.050 and 0.250; gpt-5-nano:batch lists 0.025 and 0.200 against 0.050 and 0.400. An agent that runs overnight evaluations rather than answering someone who is waiting should be priced on that row.
What the price sheet does not tell you
Four things decide whether a cheap model is usable in a loop, and none of them are in the models endpoint.
- Tool-call reliability. A model that emits malformed arguments costs a retry, and one retry at 1,555 input tokens erases the difference between the 0.025 and the 0.046 rows. Test with your own schemas, not with a benchmark.
- Rate limits. The published price says nothing about requests per minute. A loop that fires 10,000 turns a day needs headroom, and a limit hit is a failed turn.
- Instruction retention across turns. The 12-record result in this profile arrives on turn one. By turn six the same context holds five results, and the model that answered well on a clean context has to answer well on a crowded one.
- Answer length control. Output price is 0.200 against 0.030 on some rows, so a model that answers in 400 tokens where another answers in 40 changes its own ranking. Constrain the format in the prompt or the price comparison stops describing your workload.
How to choose, in order
- Count your own turn first. The 1,555-token profile here is one shape; a loop that returns 50 rows instead of 12 will be dominated by that block and the model choice will matter less.
- Shrink the input before shopping. Compact JSON to a flat table cut 15 percent of this turn for free, and the tool schema is another 245 tokens that can often be trimmed.
- Set the output budget. At 42 output tokens, input price is 82 to 97 percent of the bill. At 400, half the ranking flips. Know which profile you are in.
- Shortlist by cost, then reject on tool-call reliability with a test that uses your actual schemas.
- Keep one expensive model for the turns that need it. Routing the hard 5 percent of turns to a model 200 times more expensive adds less to the bill than routing all of them to it.
The input side of the same bill is measured in the MCP tool schema count. The format change that cuts 15 percent of this turn has its own measurement in the eight-format comparison. What embedding calls cost at scale is in the embedding price table.
FAQ
Is the cheapest model always the right one? No. On this profile the four cheapest rows are within $0.03 per 1,000 turns of each other, which is noise next to the cost of one bad tool call. Pick inside that band on reliability.
Why is the spread 210x rather than thousands? Because the turn is input-heavy and short on output, and the cheapest rows are real small models rather than promotional credits. A long-answer profile widens the gap: the same table spans $0.041 to $10.665 at 400 output tokens.
Are these provider prices? They are the list prices served by OpenRouter on 2026-11-24, which routes to upstream providers and may add margin. Direct prices from each provider can differ, and the ordering between two close rows can flip.
Do the free models really cost nothing? Fifteen entries listed zero prompt and zero completion price that day. Free tiers carry their own rate limits, and this test did not measure them, so budget for the possibility that the free channel disappears or throttles.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.