DEV Community

Long AI
Long AI

Posted on

A 20-step agent loop on six models: the same task bills 35x apart

Agent cost estimates usually start with a per-token price and a guess. This note replaces the guess with arithmetic: one fixed 20-step loop, priced against six text models at their official rates, then priced again at the best live quote on the marketplace. Everything below is reproducible from the public price table and the public model-plaza endpoint.

The loop we are pricing

The shape matters more than the specific numbers. Our loop is a tool-using agent that keeps its whole history: step one sends a 2,000-token prompt, every later step re-sends everything before it plus 400 new tokens of tool output, and each step returns 300 output tokens. After 20 steps the prompt has grown to 9,600 tokens, and the cumulative input across the run is 116,000 tokens against 6,000 output tokens.

Two properties of that shape drive every number below. First, input tokens are billed at every step, not once — the naive estimate of "one call, 2,000 tokens in" understates the run by roughly 5.8x. Second, output tokens are billed once each but usually cost 4–7x more per token than input, so a loop with short answers still pays a lot of output.

Six models, one loop, a 35x spread

Official per-million-token rates, snapshot 2026-12-03 19:05 (UTC+8):

Model Input $/1M Output $/1M Cost of the 20-step run Live sellers
gpt-6-astra 10.00 50.00 $1.46 12
claude-opus-5 5.00 25.00 $0.73 9
gpt-5.6-sol 4.00 20.00 $0.58 12
kimi-k3 2.99 14.94 $0.44 4
gemini-3.5-flash 1.50 9.00 $0.23 1
deepseek-v4.1-flash 0.30 1.19 $0.04 9

The cheapest run is $0.0418 and the most expensive is $1.46 — 35x. Same prompt, same 20 steps, same 300-token answers. A team that benchmarks on "quality per dollar" without fixing the loop shape will conclude the wrong model is cheap, because the 35x is not spread evenly across input and output.

Where the money actually goes

Split the bill by component and the ranking changes. For gpt-6-astra, input accounts for $0.86 of the $1.46 and output for $0.60 — output is 41% of the bill on only 5% of the tokens. For deepseek-v4.1-flash the same split is $0.026 input and $0.021 output, so output is half the bill. The ratio of output price to input price differs by model: 5.0x on gpt-6-astra, 4.0x on deepseek, 6.0x on gemini-3.5-flash.

The practical consequence: if your agent's answers are long — summaries, code, reports — output price dominates and the input-side discount you negotiated barely moves the total. If your answers are short and the context is huge, it flips. Optimising the wrong side is the single most common way agent budgets go wrong.

The same loop at marketplace quotes

Official price is the ceiling, not the bill. The same six models carry live seller quotes with a stated percentage below official price. At the deepest quote currently listed, the 20-step run reprices as follows: gpt-6-astra $0.0117 (99.2% below official), claude-opus-5 $0.0321, gpt-5.6-sol $0.0099, kimi-k3 $0.0240, gemini-3.5-flash $0.0251, and deepseek-v4.1-flash $0.0023.

Notice what happened to the ranking: gemini-3.5-flash, third cheapest at official price, becomes more expensive than gpt-5.6-sol at marketplace quotes, because its deepest quote is shallower (10% below official versus 98.3%). Any comparison done at official price only is a comparison of list prices, not of what you would pay. The live quotes and their depth are on the price table, and each model's quote ladder is visible per model on the model plaza.

Pricing it yourself

The whole calculation is 20 lines. Pull the model list, keep the official input and output prices, and accumulate per step instead of per call:

import json, urllib.request

API = "https://ai.dijinlong.com/api/v1/model-plaza"

def models():
    req = urllib.request.Request(API, headers={"User-Agent": "loop-cost/1.0"})
    with urllib.request.urlopen(req, timeout=30) as r:
        return json.loads(r.read().decode("utf-8"))["data"]["groups"][0]["models"]

def run_cost(m, steps=20, base=2000, growth=400, out=300):
    op = m.get("official_pricing") or {}
    inp, outp = op.get("input_price"), op.get("output_price")
    if not inp or not outp:
        return None
    return sum((base + growth * i) * inp + out * outp for i in range(steps))

for m in models():
    c = run_cost(m)
    if c is not None:
        print(f"{m['name']:<28}{c:>8.4f}")
Enter fullscreen mode Exit fullscreen mode

Two details make the output trustworthy. The loop counts input per step, not once — the mistake that produces estimates 5x too low. And it reads official_pricing rather than the live quote, so the number is a stable ceiling you can compare across models; apply the quote percentage afterwards if you want the expected bill.

What to do with this

  1. Fix the loop shape before comparing models. Steps, context growth and answer length change the ranking more than the per-token price does. A 20-step loop with 400-token growth is a reasonable default; publish your own shape next to any cost claim.
  2. Split input and output when you optimise. Caching, trimming history and shorter tool schemas attack input. Shorter answers, stricter max_tokens and less verbose formats attack output. They are not interchangeable.
  3. Price at the quote, decide at the ceiling. Budget on official price so a seller leaving does not blow the plan; compare vendors on the live quote. The gap between the two is where the risk sits, and per-model quote depth is the only way to see it — the same fields are documented on the model reference pages and recurring questions are collected on the FAQ.

All figures above come from one snapshot: 2026-12-03 19:05 UTC+8, 100 models and 357 live seller quotes. Re-run the script a week later and the absolute numbers move; the 35x spread between the cheapest and most expensive run does not, because it comes from list prices that are repriced far less often than quotes are.

Top comments (0)