DEV Community

Cover image for How much does it cost to run a text game with LLMs

How much does it cost to run a text game with LLMs

Aliaksei Zelianouski on November 08, 2026

AI costs are confusing. Providers give you a lot of numbers and nothing to actually know how much you are going to pay in the long run. There is no...
Collapse
 
pengeszikra profile image
Peter Vivo • • Edited

Hi Aliaksei! Thank you to share your detailed AI cost and experience those information is very valuable for me. My game building idea is bit different. My game just use a partial AI instead of core mechanic. I don't register player, just let them play it. Maybe take a look:

Collapse
 
hiper2d profile image
Aliaksei Zelianouski • • Edited

Nice work. However, our games are quite different. Your's doesn't seem to have any AI making decisions or actually playing. Which is probably a smarter use of AI. When I started mine, I haven't though about budgets and tokens - I just wanted to build it for myself. I only realized how expensive it is to run after the shipment.

I have to register users to track and limit the spendings. The fact than I only take their emails creates a lot of possibilities for the players to trick me. People create multiple accounts, use VPN + incognito mode to bypass my checks. It would be easier if I asked more info from the players, but try to stay aways from this as much as I can.

Collapse
 
onelifevibe profile image
OneLifeVibe •

The cache result that surprised me most was the 1-hour cache costing more — 3.13¢ a turn versus 2.94¢ with no cache at all — because the write premium only pays off if the cached tokens actually get read back. Pairing that with the structured-output finding, that votes and night actions barely hit cache because the JSON schema invalidates it for OpenAI, Google, Mistral and Meta, makes this feel like a field guide rather than a price list. The $6.36-a-day headline for six daily users is remarkably concrete too — did the Sonnet-versus-Haiku gap, 17x the cost per turn at the same speed, change which models you let into free games?

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

Yeah, it did. In the very beginning, I just select models randomly for each game. A player can always change that if they like. Now, the random selection allocate more sits to cheaper models and a player is limited in selecting expensive model combinations. Sonnet is too expensive for a free tier - even one model a game pushed the price up by a lot.

Collapse
 
aiapikey profile image
于侃 •

That schema result has a mechanical cause, and it is fixable. Schemas usually land after the variable part - tool definitions appended last, or the schema string pinned to the tail - so the shared prefix ends before them and every request forks at the same point.

Put the schema and the static instructions at the very front, keep per-request state and turn counters strictly at the tail: on the structured-output loads I have logged, prefix hit rate went up 40-70 points.

The write premium is the same effect read off the invoice - you paid to write a prefix that was never read twice.

Collapse
 
sreno77 profile image
Scott Reno •

This is very interesting. Are you trending toward having enough paid users to cover your free users?

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

I am not, I have zero paying users. Someone tried recently, but Stripe rejected a credit card from Russia. I added crypto payments the same day, but the person never returned.

My plan was to get users, create a community, and only then start thinking of the monetization. I can always shrink the free tier features and limits but I haven't yet reached the level os spendings where I really have to do that.

Collapse
 
maxbuildsdev profile image
Max Kaya •

The 1-hour cache section hurts because it's so easy to walk into. With a chatty session-style loop the median gap between calls decides everything, and the 5-minute default was already borderline before the write premium got involved.

One question on the "every switch to a JSON turn cleared the cache" bit — is that because the serialized turn contains volatile fields (ids, timestamps) so the prefix diverges? If so, moving all the volatile fields to the end of the serialized block and freezing everything before it keeps the cached prefix stable even when the turn changes; that helped in a similar setup we ran.

Also curious: was the stats-pricing bug (cache writes priced at the normal rate) in your own metering layer, or were you reading cost from the response usage field? That distinction seems to decide whether you catch it in your own dashboard or only on the invoice.

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

I really don't see the reason to clear the cache when switching to the JSON mode mid-session. Chinese models don't do that. My case is probably rare, so nobody cares. It's just something to know about. I used to use JSON mode for everything but then I noticed that it takes longer - somehow the same input with the plain text response type can be easier for morels.

No provider hands us a dollar amount. I read the token breakdown from the response and then apply the costs from the config. So yeah, I had lots of bugs in this logic. Prices can be very tricky to follow. The cache storage price is a black box, responses don't reveal it.

Collapse
 
aifrontierpost profile image
AI Frontier Post •

Sonnet 5.5 costs 17 times Haiku per turn, 3.10 cents versus 0.18, for a median reply only 0.6 seconds faster. At that gap, the expensive model only makes sense if the extra quality shows up in the game, not the latency.

Collapse
 
paullovelace profile image
Paul Lovelace •

The 1-hour cache costing more than no cache is the line that stuck with me — 3.13¢ vs 2.94¢ a turn, and the write premium only pays off if the prefix actually gets read back. I keep coming back to the free-tier math though: $5 a day per user, 651 free users, zero paying. How close have you actually come to the 'oh no' number, or does the alert just never fire because retention is that low?

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

The math is simpler if to look at the active or daily users only. It's $6-7 a day on average. The worst days I had were not because of sudden spikes but because of abusers - some players created multi-accounts and burnt me $20/day. But it's rare.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@hiper2d Agreed for a welcome message. The cost is in long sessions, where the whole context goes out again on every turn: Tokenade cut session cost 39% on average in the THOL benchmark (2026-09-14, raw data public).

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

Reasoning tokens bill as output, so in a long game that hidden line can outweigh the visible text.

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

Yes, outweighs by a lot. By default, many models tend to reason to the roof. 1000-4000 tokens on a simple question easily. I had to tune this down by lowering the reasoning effort and output budget in pretty much every Chinese model. It's nice when models support adaptive reasoning - this usually keep the output tokens tight on simple text questions.

Collapse
 
aiapikey profile image
于侃 •

Worth measuring the ratio rather than the absolute: reasoning tokens as a share of billed output. In multi-turn game loops I have seen 40-60% once the model starts planning moves, and the share grows with turn count because the visible reply stays short while the deliberation does not. Two cheap checks: log reasoning_tokens separately from output_tokens, and cap it per turn - an uncapped reasoner in a 20-turn session can spend more thinking about a move than the move itself costs.****

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@hiper2d Same experience: effort had to be tuned by hand, model by model. THOL, 2026-09-14: 39% lower session cost on average on long Claude Code runs, raw data public.

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

Higher reasoning in coding usually makes sense. Although, yeah - it depends. In my case, it didn't make sense to reason on high for a simple welcome message to the chat.

Collapse
 
aiapikey profile image
于侃 •

The number to pin down is cost per playable turn, not cost per 1M tokens. A text game is mostly fixed system prompt plus world state, so a 4k-token prompt at $0.10/M costs $0.0004 per turn before the model writes a word. At 60 turns an hour that is $0.024/hour of pure prompt repetition - which dwarfs the output cost and is where prefix caching actually pays. Two things I would measure separately: cost of a turn the player accepts versus cost including retries, and what fraction of the prompt is a cacheable prefix. In my experience rejections eat 20-40% of the budget while looking like model cost.

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

I don't have any rejections. A user doesn't have an option not accept. Some request might fail with a timeout, there are some rare failures on the provider's end, certain images instructions can be locked by Google, but overall, rejected calls are not that significant cost-wise

Collapse
 
aiapikey profile image
于侃 •

Fair point - if there is no rejection path, my 20-40% figure does not apply here. The residual line I would still watch is requests that are billed but produce nothing usable: a timeout on the provider side or a policy block that fires after the prompt was already tokenized can still appear on the invoice. Called-out as rare, but on a long session it is a few percent, and without a billed-but-failed counter it hides inside the per-turn average and reads as model price. That counter is cheap: one integer per turn, next to the token count you already log.

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

The 1-hour cache costing 3.13 cents a turn against 2.94 with no cache at all is the kind of result nobody finds from a pricing page. The write premium only pays back if the prefix gets read again, and a chatty game with gaps between turns is exactly where it does not.

Logging tokens, cache hits, cost, and time for every call is the real lesson here. Cost per turn, and ideally cost per finished game as someone suggested, is a number you can make decisions on. Per million tokens is not, once reasoning tokens and cache behavior differ by model.

At Ascendra Ventures we ask for that kind of per-call log before agreeing a fixed price on any AI feature, because the running cost often decides the design more than the build does. Your Sonnet versus Haiku gap, 17 times the cost for 0.6 seconds of latency, is a good example.

Has the data changed which models you offer on the free tier by default, or only the weighting of the random pick?

Collapse
 
richard_verifies profile image
Richard •

Your $6-7/day answer and the $20 abuse day point the same way: spend tracks accounts, not retained users. So $5/day is a ceiling per account, and there is no ceiling on how many accounts show up. What stays fixed while that grows is a global daily budget, with the bands you already have doing the degrading once it is crossed (free games down to the <=0.3c band), instead of a per-user cap that only binds for one honest player. Is there a global ceiling anywhere in the setup, or is $5/user the only one?

Collapse
 
alexshev profile image
Alex Shev •

The per-turn bands are much more actionable than provider rate cards because they absorb context growth, caching, and reasoning. I would also watch the p95 cost per completed game: a rare runaway summary or retry loop can be invisible in an average while it decides whether a free tier is sustainable.

Collapse
 
devkursat profile image
Kürşat Yılmaz •

The obsession with wrapping remote APIs into multi-layered agent abstractions is creating massive hidden latency and failure cascades in production.

If you profile real-world workloads, bare-metal local inference (via direct C++ / llama.cpp or vLLM bindings) consistently beats fragile cloud wrappers on both predictability and cost. Tooling should eliminate abstraction penalties, not compound them.

Collapse
 
aiapikey profile image
于侃 •

Agreed on the abstraction penalty, but it is worth quantifying because the number changes the decision: a well-run proxy hop adds 5-15 ms and near-zero failure rate, so the wrapper itself is rarely the problem - unretried flapping and cross-region egress are. Local clearly wins when the model fits your GPU and you own the queue. A wrapper wins when the model you need is behind an endpoint you cannot host - which is still true for most Chinese frontier models - and then the honest comparison is wrapper latency versus not having the capability at all.

Collapse
 
hiper2d profile image
Aliaksei Zelianouski •

Bare-metal inference of what hardware? I don't have a personal datacenter with a bunch of B300. And having only open-weight models will kill all the fun.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
aiapikey profile image
于侃 •

That inversion is the tell. Cache writes are usually charged at a premium and reads at a discount, so break-even is per prefix lifetime, not per turn - you need roughly two reads of the same prefix before caching beats not caching at all. Losing 6% (3.13 vs 2.94 cents) usually means either the prefixes are too short-lived to be reused, or the hit rate sits under ~60%. Logging prefix id plus hit/miss per turn is what turns that from a bet on reuse into a number you can act on.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@aiapikey Agreed on the ratio. The absolute number hides the trend: the share climbs with turn count because the visible reply stays short while the deliberation does not.

Collapse
 
spritefuse profile image
Chaowen Tan •

images being 28% of the bill surprised me. great breakdown