---
title: "The best API for coding agents"
canonical: "https://router.xark.io/use-cases/coding-agents"
description: "Which open-weight models suit an autonomous coding agent, what a month of real agent traffic costs, and why cached-input pricing dominates the bill."
section: "use-cases"
updated: "2026-09-02"
source: "https://router.xark.io/use-cases/coding-agents.md"
---

# The best API for coding agents

For coding agents the deciding cost is cached input, not output: an agent resends the same system prompt, tool schema and file context on every step, so a model with a cheap cached-input rate can cost several times less than a nominally cheaper one without it. GLM-5.2 at $0.82 per million input and $0.16 cached is the strongest fit in this catalogue.

**Availability:** 7 of the 24 catalogued models are callable today. The rest are listed at their intended rate but no configured upstream serves them, so a request naming one returns `no available channel`. Every table below marks which is which.

## Why this workload is different

A coding agent is a loop, not a conversation. Each step resends the system prompt, the tool definitions and a slab of file context, then asks for a small diff. The input-to-output ratio is often 50:1 or worse, which inverts the usual pricing intuition — output rate barely matters and input rate is almost the whole bill.

That is why cached-input pricing decides this workload. The repeated prefix is served from the model's KV cache at a fraction of the standard input rate, and for an agent that prefix is most of every request. A model with no published cached rate is not cheaper; it is a model whose largest line item is unpriced.

## What actually matters when choosing

| Criterion | Why it decides this workload |
| --- | --- |
| Cached-input rate | The agent's repeated prefix is the bulk of its tokens. This number, not the headline input rate, is what the monthly bill is mostly made of. |
| Context window | Enough room for the system prompt, tool schemas and several files at once. Running out mid-task forces re-planning, which costs a full round trip. |
| Tool-calling reliability | An agent that returns malformed tool calls burns a retry every time. That failure is invisible in a price comparison and expensive in production. |
| Licence | Agents get embedded in products that ship. A permissive licence removes a question legal will otherwise ask late. |

## Recommended models, priced at a working agent, ~2,000 steps/month

| Model | Our monthly cost | Official monthly cost | Saving | Callable | Document |
| --- | --- | --- | --- | --- | --- |
| GLM-5.2 | $348.40 | $595.20 | 42% | Yes | [read](https://router.xark.io/models/glm-5-2.md) |
| Kimi K3 | $812.00 | $1,320.00 | 40% | Yes | [read](https://router.xark.io/models/kimi-k3.md) |
| DeepSeek V4 Pro | $116.40 | $180.96 | 37% | Yes | [read](https://router.xark.io/models/deepseek-v4-pro.md) |

## Questions

### Does cached input really change the total that much?

On an agent workload it is usually the largest single factor. If 80% of your input is a repeated prefix billed at roughly a fifth of the standard rate, the effective input cost falls by about two thirds — a bigger swing than the difference between most models' headline rates.

### Can I pin an agent to one model?

Yes. Send the exact model id and no substitution happens. Fallback only applies if you ask for it, which matters for an agent whose prompts were tuned against one model's behaviour.