Skip to content
AI Dev Toolkit.
Esc
  • Loading…

Guide · Coding agents

The best model for coding agents, and how to choose one

The best model for a coding agent is the one that finishes your tasks reliably at the lowest cost per task, not the leaderboard leader. Judge models on dependable tool calls, context and output room, speed and price. Agents resend their context on every step, so input price and prompt caching decide most of the bill.

By Tahir NazirUpdated 13 min read

On this page
  1. Which model is best for coding agents right now?
  2. Coding agent or model: what is the difference?
  3. What matters when choosing a model for a coding agent?
  4. Why agents cost more than chat, and how to price a task
  5. Tool-use reliability
  6. Context window and output limit
  7. Speed and reasoning modes
  8. What is the best open-weight model for agentic coding?
  9. What benchmarks like SWE-bench tell you
  10. A simple way to choose
  11. Questions people ask

Which model is best for coding agents right now?

No single model stays best for every team, so start from a dated shortlist and test it on your own tasks. Here are starting points computed today (2026-11-22) from our price data and the example task priced further down. They rank cost, not quality: a cheaper model only wins if it finishes your tasks as reliably.

Starting points from our data (2026-11-22)
If you wantModelExample task, cachedContext window
Lowest cost per taskClaude Haiku 5.5$0.01011,000,000 tokens
Lowest cost with a 1M-token windowClaude Haiku 5.5$0.01011,000,000 tokens
Lowest cost with reasoning controlsClaude Haiku 5.5$0.01011,000,000 tokens
Lowest cost with open weightsQwen3.8 Flash$0.01221,000,000 tokens

Chosen from the tool-capable models in the price table below, which refreshes daily. The task is an example, not a benchmark.

A practical shortlist for hard, multi-file work is one provider flagship and one cheaper model from this table, compared on 10 to 20 real tasks. The rest of this guide explains what to measure.

Coding agent or model: what is the difference?

The agent is the program that reads files, runs commands and edits code; the model is the LLM it calls on every step. Claude Code, OpenAI Codex, Cursor and GitHub Copilot are agents, and most let you choose the model:

  • Claude Code runs Claude models. Switch with /model in a session or claude --model at startup; aliases such as sonnet, opus and haiku pick the latest of each. If it reports an issue with the selected model, /model picks another.
  • Cursor supports models from OpenAI, Anthropic, Google and others.
  • GitHub Copilot’s cloud agent lets you pick the model, or Auto, when you assign an issue or start a task from supported places.
  • OpenAI Codex runs in the ChatGPT apps, a CLI, an IDE extension and the cloud, with a choice of OpenAI models.

So pick the agent for its workflow (terminal, editor or pull requests) and the model for reliability and cost per task. Whichever agent you use, a short instruction file such as CLAUDE.md or AGENTS.md saves the model from rediscovering your project on every task; the CLAUDE.md generator writes one.

What matters when choosing a model for a coding agent?

A coding agent is a loop: the model reads files, calls tools, edits code and runs tests until the task is done. The model you want is the cheapest one that finishes your tasks reliably inside that loop. Seven criteria decide it:

  1. Tool-use reliability: well-formed calls, the right tool, no loops.
  2. Context window: room for the repository slices, tool output and history a task accumulates.
  3. Output limit: room to write a large file or a long patch in one reply.
  4. Speed: how long a task takes end to end, which shapes how you work with the agent.
  5. Price per task: what a finished task costs, including caching, not the price per token.
  6. Reasoning controls: whether you can turn thinking up for hard steps and down for easy ones.
  7. Where it runs: the provider’s API, a cloud you already use, or open weights you host yourself.

Rankings change often, so this guide doesn’t name a winner. It shows how to judge each criterion and gives live prices for the current tool-capable models.

Why agents cost more than chat, and how to price a task

Every step of the loop is a new API request that resends everything so far: the system prompt, tool definitions, the task, every file read and every test log. Here is one small example task, a bug fix in eight steps:

Each request carries everything before it. Most of each bar was already sent in the previous step, which is exactly what prompt caching makes cheap.

The task bills 237,300 input tokens against 5,700 output tokens. Without caching, input is 89% of the cost on Claude Sonnet 5.5, even though its output price is 5× its input price. With caching, each step pays the cheap cached rate for everything it re-sent, and the bill for this task falls by 57% to 73% across the models below that list a cache price. A longer task has more steps, each resending more, so the gap grows.

Tool-capable models and what the example task costs (prices as of 2026-11-22), cheapest with caching first
ModelOpen weightsContext windowInput / cached / output per 1MTask, no cachingTask, cached
Claude Haiku 5.5No1,000,000$0.10 / $0.01 / $0.50$0.0266$0.0101
GPT-6 LunaNo1,050,000$0.10 / $0.01 / $0.50$0.0266$0.0101
Qwen3.8 FlashYes1,000,000$0.15 / $0.016 / $0.47$0.0383$0.0122
DeepSeek V4.1 FlashYes1,048,576$0.30 / $0.006 / $1.20$0.078$0.0208
gpt-oss-120bYes131,072$0.09 / – / $0.36$0.0234$0.0234
Mistral Large 4Yes1,048,576$0.70 / $0.07 / $2.10$0.18$0.0555
Gemini 3.8 FlashNo1,048,576$0.825 / $0.083 / $4.125$0.22$0.0748
DeepSeek V4 Pro 0423Yes1,048,576$0.90 / $0.20 / $1.50$0.22$0.0859
GLM 5.3Yes1,048,576$1.40 / $0.26 / $4.40$0.36$0.14
Claude Sonnet 5.5No1,000,000$2 / $0.10 / $10$0.53$0.18
GPT-6.1 SolNo1,050,000$2 / $0.10 / $10$0.53$0.18
Gemini 3.1 Pro PreviewNo1,048,576$2 / $0.20 / $12$0.54$0.19
Grok 4.7No500,000$2 / $0.50 / $6$0.51$0.22
Kimi K3Yes1,048,576$3 / $0.30 / $15$0.80$0.27
Claude Opus 5.5No1,000,000$4 / $0.20 / $20$1.06$0.37
Claude Fable 5.1No1,000,000$10 / $0.25 / $50$2.66$0.87
GPT-6 AstraNo1,050,000$10 / $1 / $50$2.66$1.01

From our daily data. “Cached” assumes each step reads the previous prompt from the cache and pays the cache-write price, where one is listed, on new tokens. Open-weight prices are typical hosted prices and vary by host. A dash means no cache price is listed.

In this example, with caching applied wherever a model lists a cache price, the cheapest model costs $0.0101 per task (Claude Haiku 5.5) and the most expensive $1.01 (GPT-6 Astra). A cheaper model only saves money if it finishes the task in a similar number of steps: a model that needs twice as many steps, or two attempts, can cost more per finished task.

Free toolLLM cost calculatorIts “Coding agent” preset prices a large, mostly cached context per request across every model. Change the numbers to match your own agent’s usage.

Tool-use reliability

Because an agent is only as good as its worst tool call. Tool calls are the model’s function calling feature, used dozens of times per task. A malformed argument, the wrong tool, or a call that repeats forever wastes steps and money. Look for these, and test them on your own tools:

  • Schema guarantees. Anthropic’s strict: true makes Claude’s tool calls always match your schema, and OpenAI’s strict mode makes function calls “reliably adhere to the function schema, instead of being best effort”. Turn them on where the provider supports them.
  • Tool count. Every definition is billed as input on every step, including the tools that MCP servers add. OpenAI suggests aiming for fewer than 20 functions at the start of a turn, and both providers offer tool search to load definitions on demand.
  • Parallel calls. Reading three files at once saves steps. Both APIs support parallel tool calls and let you switch them off when order matters.
  • Asking instead of guessing. Anthropic notes that Claude Opus is much more likely than Sonnet to ask for a missing required parameter rather than infer one, and that this is less dependable on less capable models.

The practical test: run 10 to 20 real tasks from your backlog and count malformed calls, wrong-tool calls and steps per task, not just whether the task passed.

Context window and output limit

Agents fill context quickly with file contents and tool output, so the window sets how long a task can run before the agent has to drop or summarise history. Of the 285 tool-capable text models in our data, 118 accept at least 1,000,000 tokens. Bigger isn’t free, though: each step pays for the whole context, and recall gets worse as context grows (see context windows explained).

The output limit matters when the agent writes whole files or long patches in one reply, and it includes any thinking. In our data, the limit per reply is 128,000 tokens on Claude Sonnet 5.5, 128,000 tokens on GPT-6.1 Sol and 65,536 tokens on Gemini 3.8 Flash. The context window checker shows whether a given file set fits with room for the reply.

For long tasks, compaction (summarising older steps on the server) and clearing old tool results keep the context small. Anthropic offers both for Claude, and OpenAI offers compaction in its Responses API.

Speed and reasoning modes

Speed decides how you use an agent: a fast model suits interactive pairing, a slow, thorough one suits tasks you hand off and review later. Anthropic labels its current lineup from “slower” (Fable) to “fastest” (Haiku), and both Anthropic and OpenAI sell faster processing for some models at a higher price.

218 of the 285 tool-capable models in our data can reason (think) before they act, and that thinking is billed as output. All three major providers let you set how much: effort on Claude, reasoning.effort on OpenAI and thinking_level on Gemini 3. A sensible pattern is a high setting for planning and debugging, and a low one, or a smaller model, for mechanical steps like renaming or formatting.

What is the best open-weight model for agentic coding?

The one that handles your tool calls reliably on the host or hardware you will actually use. Of the open-weight models in the price table, Qwen3.8 Flash, DeepSeek V4.1 Flash, gpt-oss-120b, Mistral Large 4, DeepSeek V4 Pro 0423, GLM 5.3 and Kimi K3 support tool calling, and Qwen3.8 Flash is the cheapest for the example task ($0.0122 with caching, at a typical hosted price). Open weights let you self-host, fine-tune and keep code on your own machines; expect to test harder, because tool-call reliability on long tasks varies more by model and by serving setup.

Where each model runs: APIs, clouds and your own hardware

If your company already buys cloud from one vendor, availability can decide the shortlist before quality does.

  • Claude is sold through Anthropic’s API, Amazon Bedrock, Google Cloud, Microsoft Foundry and Claude Platform on AWS. Bedrock and Google Cloud set their own prices.
  • OpenAI’s models are sold through OpenAI’s API, Microsoft Foundry on Azure and Amazon Bedrock.
  • Gemini is sold through the Gemini API and Google Cloud’s Gemini Enterprise Agent Platform (formerly Vertex AI), which also hosts Claude and open models.
  • Open-weight models can be downloaded and run on your own hardware or rented from many hosts. Our data lists 134 open-weight models with tool calling. Running a large one yourself needs a lot of GPU memory; the VRAM calculator estimates how much, and our guide to how much VRAM you need explains the maths.

What benchmarks like SWE-bench tell you

SWE-bench is a widely used coding-agent benchmark. Each task is a real GitHub issue: the system gets the issue text and a copy of the repository, must change the code to fix it, and passes only if tests that failed before the original fix now pass. The original set has 2,294 tasks from 12 popular Python repositories.

  • SWE-bench Verified is a 500-task subset whose problem statements, tests and solvability were checked by human annotators, created with OpenAI.
  • SWE-bench Multilingual has 300 tasks from 42 repositories in 9 programming languages, useful if you don’t write Python.
  • Bash Only runs every model in the same minimal agent (mini-SWE-agent), so the scores compare models rather than agent harnesses. The site also charts results against cost and step count.

Use benchmarks to build a shortlist, not to make the final call. A leaderboard entry is a whole system (model plus agent), most tasks are Python, and your repository, tools and conventions are different. Scores also change as new models arrive, which is why we don’t quote them here.

A simple way to choose

  1. Shortlist three models in the model comparison: filter for tool calling and the context you need, then add one cheaper model and one stronger one.
  2. Run your own tasks. Take 10 to 20 closed issues from your backlog and run each through your agent on each model, with caching on.
  3. Measure per task: pass rate, cost (from the API’s usage figures), wall-clock time and failed tool calls.
  4. Pick the cheapest model that passes, and consider routing easy tasks to a smaller model.
  5. Recheck every few months. New models and price cuts arrive often; the prices on this page update daily.

FAQ

Questions people ask

What is the best model for coding agents?

There isn’t one that stays best for everyone. The right model is the cheapest one that reliably finishes your tasks with your tools and your codebase. Shortlist two or three from benchmark results and live prices, run 10 to 20 of your own tasks through each, and compare pass rate, cost per task and time.

What is the difference between a coding agent and a coding model?

A coding agent is the program that reads files, runs commands and edits code, such as Claude Code, OpenAI Codex, Cursor or GitHub Copilot. The model is the LLM the agent calls on each step. Most agents let you switch models, so choose the agent for its workflow and the model for reliability and cost per task.

Is Claude Code the best coding agent?

It depends on how you work. Claude Code works in the terminal (and in IDEs and a desktop app) and runs Claude models; Cursor is an editor that offers models from several providers; GitHub Copilot’s agent works from issues and pull requests on GitHub; OpenAI Codex runs in the ChatGPT apps, a CLI, an IDE extension and the cloud. Try two on the same real task and compare the result and the cost.

Why are coding agents so expensive to run?

Because every step resends the whole conversation: system prompt, tool definitions, files read and test output. In our eight-step example the agent bills 237,300 input tokens to write 5,700. Prompt caching makes the re-sent part much cheaper, which is why it matters so much for agents.

Is there a free model good enough for coding agents?

Open-weight models are free to download, and our data lists 134 with tool calling, but running a large one needs a lot of GPU memory; the VRAM calculator estimates how much. Some APIs also have free tiers with rate limits, such as Google’s Gemini API. Test tool calling on long tasks with the exact host or setup you plan to use.

What does SWE-bench measure?

Whether a system can resolve real GitHub issues: it gets the issue and the repository, edits the code, and passes if tests that the original fix made pass now pass. Verified is a 500-task human-checked subset; Multilingual covers 9 languages. It measures model and agent together, on mostly Python projects.

Should I turn reasoning or thinking on for a coding agent?

For planning and debugging, usually yes; for mechanical edits, often no. Thinking tokens are billed as output and count toward the output limit, so a high setting on every step adds cost and time. Set the effort per task, or route simple steps to a cheaper model.

Try it

Tools from this guide

Glossary

Key terms in this guide

Keep reading

Keep exploring