What you’ll learn
- Which cheap AI model is best for agents?
- Why rank by cost per task and not by price per token?
- Are the cost-per-task numbers what I would pay on TokenLab?
- Why is claude-haiku-5-5 not in the ranking?
- How do tool-calling retries change the cheapest model choice?
The cheapest model per token is rarely the cheapest model per finished task. An agent calls the model many times, re-sends its history on every call, and pays again for every retry. This ranking therefore uses cost per task, not price per token. It combines public results from Artificial Analysis with TokenLab prices. Everything was read on 2026-11-11.
Key Takeaways
- Best default for cheap agent work:
gpt-6.1-terraat its high or xhigh setting. It scores 46.3 to 48.2 on the Coding Agent Index at $0.54 to $0.69 per task, and its TokenLab price is $0.30 input and $1.50 output per 1M tokens. - Cheaper alternative at a similar score:
deepseek-v4.1-flash. It scores 46.3 to 47.3 at $0.30 to $0.39 per task, but it needs 21 to 38 minutes per task, against 13 for Terra at the high setting. - Cheapest overall:
gpt-6-luna($0.16 per task, 31.2) andgpt-6.1-terraat the low setting ($0.20, 34.9). Use them for routing, extraction, and short tool calls. - Escalate hard steps to
gpt-6.1-sol: 54.1 at $1.50 per task. Premium models cost far more.claude-opus-5-5scores 61.7 at $11.42 per task. - A low token price does not guarantee a low task cost.
claude-haiku-5-5costs $0.035 input and $0.175 output per 1M tokens, which is 12% of thegpt-6.1-terraprice, and still costs $2.67 per task.
How the Ranking Works
- Score. The Artificial Analysis Coding Agent Index v2.0 runs a coding agent on three benchmarks: FrontierCode v1.1, Terminal-Bench 4.0, and SWE-Atlas-QnA-AA. It averages the three scores on a scale of 0 to 100. Each task runs three times. The methodology page has the details.
- Cost and time. Cost per task is the average pay-per-token API cost of a task at the provider's list price, including cache-read and cache-write prices. Time per task is the average agent wall time. Both come from the same runs.
- Which entries. Only models that are active or in preview on TokenLab. Only entries that score at least 30 and cost less than $2 per task. Each agent and setting is its own entry, because the setting changes both score and cost.
- Order. Lowest cost per task first. When two entries cost the same, the higher score ranks first.
The index measures coding agents that read files, run commands, and call tools. It does not test your own tools, so run your own tasks before you commit (see the last section).
Best Cheap AI Models for Agents, Ranked by Cost per Task
| Rank | TokenLab model ID | Agent and setting | Index | Cost per task | Time per task | TokenLab price per 1M tokens, input / output |
|---|---|---|---|---|---|---|
| 1 | gpt-6-luna |
Codex, max | 31.2 | $0.16 | 21 min | $0.03 / $0.15 |
| 2 | gpt-6.1-terra |
Codex, low | 34.9 | $0.20 | 6 min | $0.30 / $1.50 |
| 3 | deepseek-v4.1-flash |
DeepSeek harness, max | 46.3 | $0.30 | 21 min | $0.15 / $0.60 (Official) |
| 4 | deepseek-v4.1-flash |
Codex, max | 47.3 | $0.39 | 38 min | $0.15 / $0.60 (Official) |
| 5 | gpt-6.1-terra |
Codex, medium | 42.0 | $0.39 | 10 min | $0.30 / $1.50 |
| 6 | gpt-6.1-terra |
Codex, non-reasoning | 39.2 | $0.45 | 10 min | $0.30 / $1.50 |
| 7 | gpt-6.1-terra |
Codex, high | 46.3 | $0.54 | 13 min | $0.30 / $1.50 |
| 8 | gpt-6.1-terra |
Codex, xhigh | 48.2 | $0.69 | 16 min | $0.30 / $1.50 |
| 9 | gpt-6.1-terra |
Codex, max | 48.1 | $1.24 | 26 min | $0.30 / $1.50 |
| 10 | gpt-6.1-sol |
Codex, max | 54.1 | $1.50 | 24 min | $0.60 / $3.00 |
| 11 | step-5-preview |
Claude Code | 43.1 | $1.84 | 61 min | $1.00 / $2.70 (Official) |
Scores, costs, and times are from the Coding Agent Index, read 2026-11-11. Prices are from the TokenLab models API, read 2026-11-11. They apply to prompts up to 272,000 input tokens. Above that, higher rates apply to the whole request on gpt-6-luna, gpt-6.1-terra, and gpt-6.1-sol.
On TokenLab, gpt-6-luna, gpt-6.1-terra, and gpt-6.1-sol have a Verified price that is 30% of the official list price: $0.03 / $0.15, $0.30 / $1.50, and $0.60 / $3 per 1M tokens, against list prices of $0.10 / $0.50, $1 / $5, and $2 / $10. Artificial Analysis computes cost at list price, so a task on the Verified route costs less than the table shows. With the default Auto delivery, a request that falls back to the Official route is billed at the Official price (billing guide). deepseek-v4.1-flash and step-5-preview have no Verified price, so TokenLab bills their Official price. DeepSeek charges double during weekday peak hours, 09:00–12:00 and 14:00–18:00 Beijing time (see the DeepSeek V4 guide).
What the Ranking Tells You
- Effort is a cost setting.
gpt-6.1-terragoes from 34.9 points at $0.20 (low) to 48.2 at $0.69 (xhigh). The max setting scores 48.1 and costs $1.24. That is 80% more than xhigh for a score that is 0.1 points lower. Set the effort on TokenLab withreasoning_effort. The accepted values depend on the model, and an unsupported value returns400 invalid_valuewith the list of accepted values. - Cost per task tracks tokens used, not only price. In these runs a task used between 1.9 and 27.2 million tokens.
deepseek-v4.1-flashin the Codex agent used 27.2 million.gpt-6.1-terraat the high setting used 5.6 million. - Time per task varies widely. Terra at the medium setting finishes in 10 minutes. DeepSeek V4.1 Flash in the same Codex agent needs 38. If a person waits for the agent, include time in your choice.
- Tool and JSON support. All models in the table list
tool-use.json-modeis listed forgpt-6-lunaanddeepseek-v4.1-flashonly. Forgpt-6.1-terraandgpt-6.1-sol, use tool calls or validate the JSON yourself.
Cheap per Token, Not per Task
Two models have low token prices on TokenLab but fall out of the ranking, because a task costs more than $2 on the same index:
| TokenLab model ID | TokenLab price per 1M tokens | Index | Cost per task | Time per task |
|---|---|---|---|---|
claude-haiku-5-5 |
$0.035 / $0.175 | 37.3 | $2.67 | 71 min |
gemini-3.8-flash |
$0.375 / $1.875 | 33.3 | $2.51 | 13 min |
The Haiku record shows one reason this can happen. Its low rate applies only to prompts up to 100,000 tokens. Above that, input and output prices are five times higher for the whole request. Always read the price tiers in GET /v1/models/{model}/pricing and compare them with the prompt length your agent reaches.
Other Low-Price Models
Some low-price models have no Coding Agent Index entry. Artificial Analysis lists these on its general LLM leaderboard. The Intelligence Index is a general score, not an agent score, so do not compare it with the table above.
| TokenLab model ID | TokenLab price per 1M tokens (Official) | Intelligence Index | Cost per task |
|---|---|---|---|
mimo-v2.6-flash |
$0.14 / $0.28 | 27 | $0.13 |
mimo-v2.6-pro |
$0.435 / $0.87 | 30 | $0.26 |
glm-5.3-flash |
$0.15 / $0.50 | 28 | $0.58 |
gpt-oss-120b |
$0.15 / $0.60 | 4 | $0.35 |
minimax-m3 |
$0.30 / $1.20 | 19 | $1.29 |
For comparison, on the same leaderboard gpt-6.1-terra at the low setting scores 29 at $0.07 per task, and gpt-6-luna at the max setting scores 28 at $0.15. The leaderboard shows no score for laguna-s-2.1 ($0.10 / $0.20), qwen3.8-flash ($0.15 / $0.47), step-3.7-flash ($0.20 / $1.15), or doubao-seed-2.1-lite ($0.12 / $0.40). Their prices are low, but Artificial Analysis had no score for them on 2026-11-11, so they are not ranked.
Failure Modes That Decide the Real Cost
- Agents re-read their history. In the Artificial Analysis runs, 92% to 98% of the input tokens in the ranked entries came from the prompt cache. So the cache-read price and a stable prompt prefix matter as much as the output price. A cache read costs 5% of the input price on
gpt-6.1-terraandgpt-6.1-sol, 10% ongpt-6-luna, and 2% ondeepseek-v4.1-flashoff-peak. Put instructions and tool definitions first and keep them unchanged between calls. Checkusage.prompt_tokens_details.cached_tokensin the response. - Thinking tokens are output tokens. They count against the output limit and are billed. If the limit is too small, the answer can come back empty and the tokens are still billed (Create Chat Completion reference). Set a limit that fits the task, and lower the reasoning effort for easy steps.
- Validate every model output. Parse the JSON, check the tool name and the arguments, and treat
finish_reasonoflengthas a truncated answer. The tool-calling guide says to validate model-produced values in your application. Make tool execution idempotent, because a retry can repeat a call. - Count retries in the price. If you rerun each failed attempt in full, the cost per solved task is the cost per attempt divided by the success rate. Example with assumed numbers: model A costs $0.20 per attempt and succeeds 50% of the time, so a solved task costs $0.20 / 0.5 = $0.40. Model B costs $0.30 per attempt and succeeds 90% of the time, so a solved task costs $0.30 / 0.9 = $0.33. The model with the lower price per attempt is not the cheaper one.
- Pin the full model ID. A retired ID can start to resolve to another model. For example,
deepseek-v4-flashnow goes todeepseek-v4.1-flash(TokenLab changelog). Readlifecyclefrom the model record, and log the model that answered.
A Routing Recipe
| Tier | Use it for | Model |
|---|---|---|
| Cheapest | Routing, classification, extraction, short tool calls | gpt-6.1-terra at low effort, or gpt-6-luna |
| Default | Multi-step agent work | gpt-6.1-terra at high or xhigh effort, or deepseek-v4.1-flash when time matters less than price |
| Escalation | A step that failed your validation | gpt-6.1-sol |
The code sends each step to the default model first. It moves to the escalation model only when the answer fails validation. It uses the OpenAI SDK against the TokenLab endpoint and the models in the table. The code sets max_completion_tokens, which newer OpenAI model families use. For other model families, set max_tokens instead. Send only one of the two. Add the retry rules from the error guide for HTTP errors.
import json
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TOKENLAB_API_KEY"],
base_url="https://api.tokenlab.sh/v1",
max_retries=0,
)
TIERS = ["gpt-6.1-terra", "gpt-6.1-sol"] # cheap default first, escalation second
TOOLS = [
{
"type": "function",
"function": {
"name": "lookup_order",
"description": "Look up an order by its ID",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}
]
def valid_tool_call(choice):
"""Accept only a complete, well-formed call to a known tool."""
if choice.finish_reason != "tool_calls" or not choice.message.tool_calls:
return False
for call in choice.message.tool_calls:
if call.function.name != "lookup_order":
return False
try:
args = json.loads(call.function.arguments)
except ValueError:
return False
if not isinstance(args, dict) or not isinstance(args.get("order_id"), str):
return False
return True
def run_step(messages):
for model in TIERS:
response = client.chat.completions.create(
model=model,
messages=messages,
tools=TOOLS,
max_completion_tokens=4000,
)
choice = response.choices[0]
if valid_tool_call(choice):
return model, choice.message
print(f"{model}: invalid tool call (finish_reason={choice.finish_reason}), escalating")
raise RuntimeError("no tier produced a valid tool call")
model, message = run_step([{"role": "user", "content": "Where is order A-1042?"}])
print(model, message.tool_calls[0].function.arguments)
To find out whether this routing pays off, run the same set of real tasks on each candidate. Use the same instructions, tools, and time limit. Then compare tasks solved, retries, total tokens, and final cost in Usage, as the cost guide describes. Keep the results by task type.
Related Reading
- AI API prices compared: list price, OpenRouter and TokenLab
- DeepSeek V4 API for coding
- Delivery tiers: Auto, Verified, or Official
FAQ
Which cheap AI model is best for agents?
By cost per task on the Artificial Analysis Coding Agent Index, gpt-6.1-terra at the high or xhigh setting is the best default: 46.3 to 48.2 points at $0.54 to $0.69 per task. deepseek-v4.1-flash scores about the same for $0.30 to $0.39 per task but runs 21 to 38 minutes per task. For the cheapest steps, use gpt-6-luna or gpt-6.1-terra at the low setting.
Why rank by cost per task and not by price per token?
An agent uses between 1.9 and 27.2 million tokens per task in these runs, and most of them are cached input. The token price alone does not tell you how many tokens a model needs, how many steps it takes, or how often it fails. Cost per task includes all three.
Are the cost-per-task numbers what I would pay on TokenLab?
No. Artificial Analysis computes them at the provider's list price. On TokenLab, the Verified price of gpt-6-luna, gpt-6.1-terra, and gpt-6.1-sol is 30% of the list price, so those tasks cost less. A request that falls back to the Official route is billed at the Official price. Check the price tiers of each model before you budget.
Why is claude-haiku-5-5 not in the ranking?
Its cost per task on the index is $2.67, above the $2 limit used here, even though its price per token is 12% of the gpt-6.1-terra price. Its low rate applies only to prompts up to 100,000 tokens. It may still fit short, simple steps. Test it on your own tasks.
How do tool-calling retries change the cheapest model choice?
A cheap model that fails tool calls or truncates JSON forces retries, and every retry adds tokens. Divide the cost per attempt by the success rate to get the cost per solved task. Validate each output and escalate only the steps that fail.
Browse current model IDs and prices on the TokenLab models page, or send your first request with the quickstart.
Sources
Prices checked 2026-11-11
- Artificial Analysis: Coding Agent IndexSources checked 2026-11-11
- Artificial Analysis: Coding Agent Index methodologySources checked 2026-11-11
- Artificial Analysis: LLM leaderboardSources checked 2026-11-11
- TokenLab API: List ModelsSources checked 2026-11-11
- TokenLab Docs: Billing and pricingSources checked 2026-11-11
- TokenLab Docs: Create Chat CompletionSources checked 2026-11-11
- TokenLab Docs: Structured Outputs & Tool CallingSources checked 2026-11-11
- TokenLab changelog: DeepSeek V4 Flash is retiredSources checked 2026-11-11



