DEV Community

Cover image for Price your coding agent from its own logs before you self-host DeepInfer
InferenceKey for InferenceKey

Posted on Originally published at inferencekey.com

Price your coding agent from its own logs before you self-host DeepInfer

Before you argue about self-hosting a model for your coding agents, read your own logs. Claude Code keeps a JSONL transcript of every model call under ~/.claude/projects, token usage included. We took one developer's transcripts from 21 September to 20 October: 129,407 calls and 26.2 billion tokens (tokens are the word fragments a model reads and bills by). Priced three ways, that month is 400 dollars on the two Claude Max 20x subscriptions he pays, 12,365 dollars at Claude API list price, and 274 dollars on DeepSeek's API.

The full breakdown of that month and the DeepInfer break-even math lives on inferencekey.com. This piece covers the trap you hit doing the same count, and the one measurement that decides whether self-hosting makes sense.

The first streaming line undercounts output by 2.4x

The answer arrives in pieces (streaming), and Claude Code logs a new line for the same call as those pieces land. The earliest line has no stop_reason yet, and its output_tokens holds only what was generated so far. Our first pass trusted it and counted 36.4 million output tokens. The final line of each call says 86.0 million.

Output is the priciest token on the list: 20 dollars per million on Opus 5.5, against 4 for fresh input. Deduplicate by message id and request id, and let the last line win:

import json
usage = {}
for line in open(path):  # each ~/.claude/projects/**/*.jsonl
    rec = json.loads(line)
    msg = rec.get("message") or {}
    if "usage" in msg:
        usage[(msg.get("id"), rec.get("requestId"))] = msg["usage"]  # last line wins
Enter fullscreen mode Exit fullscreen mode

Do this before any pricing: every later figure inherits the error.

Your agent is a reader, so compare the cache price

On every step the agent resends the whole conversation. Providers keep recently seen text in a cache, a store that lets them skip work on text they processed a moment ago and bill it at a lower rate. In this month, 25,253 million tokens came back out of that cache. 822 million were new material written into it, and 86 million were output. That is about 303 tokens read per token written, and the median call carried 138,000 tokens of context (everything sent along with that call).

A coding agent mostly reads: 25,253M tokens re-read from cache, 822M new tokens, 86M written, about 303 read for each token written

So the headline input and output prices are the wrong columns. The cache-hit price carries the bill. Opus 5.5 charges 0.20 dollars per million cached tokens; DeepSeek off-peak charges 0.003, 67 times less, and that explains almost the whole gap between 12,365 and 274. With no cache at all, the same month on Claude would come to about 109,900 dollars.

Two details if you reprice your own month. DeepSeek doubles its rates at peak hours, so use your team's real hours (here 9.4% of usage fell in peak and paid 17.2% of the bill). And keep it a price comparison: Flash and Opus are different models with different tokenizers, that difference is unmeasured, and nobody replayed this month of work on Flash. On quality, Flash topped LiveBench agentic coding among 69 models on 10 October, the same table we used when we ran DeepSeek-V4.1-Flash on two GPUs. Opus 5.5 leads the broader Artificial Analysis Intelligence Index, 58 to 39.

DeepInfer ships the engine, not the cache

DeepSeek open-sourced DeepInfer, the engine behind its own API, under Apache 2.0. It grew out of vLLM and takes ideas from SGLang and TensorRT-LLM. Credit to all of those teams, and to DeepSeek for documenting its production setup with real numbers in a post on Zhihu.

This release does offline inference: you feed it prompts from a Python script, and there is no documented HTTP server for your agents to call. The project page also lists three missing pieces of a complete service. One is the KV cache system, the store for already-processed context (the cache from the previous section). Another is the split between prefill machines, which read the prompt, and decode machines, which write the answer token by token. The last is load balancing across copies of the engine.

DeepInfer at DeepSeek: a front door, a reading room of 8-GPU machines, a writing room of 64 to 128 GPUs, and a memory shelf on a separate SSD cluster that you build yourself

For this workload the cache is the whole game. With one, an 8-GPU server at DeepSeek's production rates holds about 293 developers like this one. Without it, each step processes the full context from scratch, and the same server holds about 15. The article budgets two full-time engineers to build the missing parts.

The one number nobody has measured yet

Every break-even figure hangs on one ratio: DeepInfer's speed per GPU on a single 8-GPU server, against DeepSeek's production, where decode runs on 64 GPUs or more. The README charts prefill on 4 GPUs and decode on 64. The 8-GPU case is missing.

Eight rented B200 at 7.99 dollars per GPU per hour cost 46,662 dollars a month. Below 58% of DeepSeek's per-GPU speed, renting never beats the API, whatever your headcount. At full DeepSeek speed, one server wins from about 262 people, engineers included, and is 11% cheaper at 293.

DeepInfer ships the benchmark (examples/sweep/run_sweep.sh), and a few hours of prefill and decode sweeps at 128K context on one 8-GPU node would settle it. We still owe that run, so treat every rented-server figure as an assumption. The own-rack estimate, about 465 people, rests on a 3.5 million dollar rack price that is our assumption, not a quote; the team-size table and every formula behind the DeepInfer break-even show what moves it.

Start with your own month

Count your team's month with the final-line rule above, then compare it with our month of coding agent costs and the DeepInfer payoff analysis.

Top comments (0)