DEV Community

Lee Jiang
Lee Jiang

Posted on Edited on Originally published at tokuse.com

How to Cut AI API Costs in 2026: Models, Caching, and Routing

AI API bills usually grow for boring reasons: every request goes to the most expensive model, the same long prefix is uploaded on every call, and no one separates interactive traffic from work that could wait until tonight. Unit price matters, but the token mix and the routing policy matter more.

Try Tokuse: Create a free account and send your first request through one OpenAI-compatible endpoint.

The DeepSeek and Doubao rates below are reference rates in USD per million tokens, checked on November 17, 2026. For Kimi, GLM, Claude, and GPT, use tokuse.com/pricing for the live price; this guide does not reproduce rates that cannot be verified in the public catalog. Model availability, groups, and promotions change. For a deeper look at DeepSeek cache economics, see the DeepSeek 2026 cost guide.

Build a cost model before choosing a discount

The number to manage is cost per successful task, not cost per token. Four inputs drive it:

  • input tokens, split into cache hits and cache misses;
  • output tokens;
  • the input and output rate of the model you route to;
  • retries, failed calls, and tokens spent on answers you throw away.

Two teams can send the same 100M tokens and receive very different bills. A team that repeats a 20K-token system prompt on every request is paying for the same text again and again. A team that puts that prompt behind a stable cache prefix pays a different rate for most of it.

What the main model families cost now

Family Example model Input / 1M Output / 1M Useful for
DeepSeek deepseek-flash $0.27 $1.10 classification, extraction, summaries, high-volume steps
DeepSeek deepseek-v4-pro $1.23 $3.70 harder reasoning when Flash misses the quality bar
Doubao doubao-seed-2-1-lite-260915 $0.11 $0.37 the low-cost default for chat and extraction
Doubao doubao-seed-2-1-turbo-260628 $0.09 $2.19 long input with very short output
Doubao doubao-seed-2-1-pro-260915 $0.82 $4.11 quality-sensitive analysis and agent steps

These are the verified DeepSeek and Doubao reference rates. They are base catalog rates before group multipliers and can differ from a provider's direct list price; the rate on tokuse.com/pricing is authoritative. Kimi, GLM, Claude, and GPT are available through the same catalog, but their current prices vary by model and group, so this guide does not print them. Check tokuse.com/pricing for those models.

Cache hits use a different billing rate from fresh input. Check the current cache terms for your model on tokuse.com/pricing before you put a number in a budget.

A reproducible comparison

Take a workload of 100M input tokens and 20M output tokens. Using the rounded rates above, the same work costs very different amounts depending on the route:

Route Input cost Output cost Total
Doubao Seed 2.1 Lite $11.00 $7.40 $18.40
DeepSeek Flash $27.00 $22.00 $49.00
Doubao Seed 2.1 Turbo $9.00 $43.80 $52.80
Doubao Seed 2.1 Pro $82.00 $82.20 $164.20
DeepSeek V4 Pro $123.00 $74.00 $197.00

These totals use only the verified DeepSeek and Doubao rates above. They say nothing about answer quality. The point is to price your own evaluation set before choosing a route, and to notice when output tokens dominate the bill.

Now split the same tokens across three tiers: 70% to Doubao Lite, 25% to DeepSeek V4 Pro, and 5% to Doubao Pro.

Route Input tokens Output tokens Input cost Output cost Total
Doubao Lite 70M 14M $7.70 $5.18 $12.88
DeepSeek V4 Pro 25M 5M $30.75 $18.50 $49.25
Doubao Pro 5M 1M $4.10 $4.11 $8.21
Blended route 100M 20M $70.34

Sending every token to Doubao Pro would cost $164.20 for this token mix. The blended route is arithmetic, not a promised result: it only holds if the cheaper models pass your quality bar for most of the work. Test that assumption on a fixed evaluation set.

Cache hits are a price tier, not a trick

Cache hits are billed at a separate rate. That rate is not fixed in this article; check the current cache-hit price for the model on tokuse.com/pricing, then apply it to the cacheable share of your input. The direction is simple: a stable prefix moves input tokens from the full input rate to the lower cache-hit rate.

The cache only helps when the prefix is stable. Put system instructions, output schemas, policy text, and long reusable documents first. Keep the changing question, user data, and timestamp after that prefix. A small edit inside a long prefix can invalidate the cache and move most of the input back to the cache-miss rate.

Some providers price cache reads and writes explicitly. Check the current cache terms on tokuse.com/pricing. The principle is the same: a stable prefix that is read repeatedly is cheaper than a prefix that is rebuilt on every call.

The levers that move the bill

1. Route by task, not by habit

Write a routing table before you negotiate a discount. A simple starting point:

Task signal Route
classification, extraction, tagging, short summaries Doubao Lite or DeepSeek Flash
RAG answers, routine code, general chat GLM-5.3 Flash, GPT-6.1 Terra, Claude Sonnet 5
hard reasoning, long-horizon agents, high-stakes review Claude Opus 5, GPT-6 Astra, Kimi K3.1 Pro
timeout, 429, provider outage a fallback in the same tier, then the next tier

This table is about task fit, not price. For the live rates of Kimi, GLM, Claude, and GPT, check tokuse.com/pricing.

Keep the model name behind an alias. A route change should be a configuration change, not an application release.

2. Make the cacheable prefix boring

Every prompt has two parts: the stable part and the changing part. Move instructions, schemas, and long references into the stable part. Put the user question and the current record at the end. Measure cache-hit tokens separately from total input tokens; a dashboard that reports only total tokens hides the most important variable.

3. Cap output before you negotiate price

Output tokens are often the largest line on the bill. Set max_tokens by task: a short classification answer, a bounded summary, a JSON object with a fixed schema. Add stop conditions where the API supports them. Then check how many output tokens each successful task actually needs.

4. Move non-urgent work off the interactive path

Search indexing, nightly reports, re-embedding, and backfills do not need to run at the same time as customer traffic. Batch them, schedule them outside peak windows, and keep interactive traffic on the fast route. DeepSeek publishes peak and off-peak rates; confirm the current schedule on tokuse.com/pricing before planning a batch window.

5. Send less context, not just a shorter prompt

Prompt compression helps, but retrieval usually helps more. Send the three relevant passages instead of the whole document. Remove duplicate instructions. Replace a long example with a compact schema when the model follows schemas reliably. Re-run the evaluation set after every change; shorter is not automatically better.

6. Treat fine-tuning as a product decision

Fine-tuning can change the unit economics for a narrow, repetitive task, but it adds training runs, evaluation work, versioning, and a new failure mode. Do it after routing, caching, and output limits are in place, and only when a smaller fine-tuned model clears the quality bar on your own data.

7. Measure cost per successful task

Log the model, input tokens, cache-hit tokens, output tokens, retries, latency, and task outcome. Then compute cost per successful task. Budget alerts are useful, but they tell you that you already spent the money. Cost per successful task tells you whether the route is getting better.

A four-week migration that keeps a rollback path

Week 1: baseline. Pick one endpoint. Record request volume, input and output tokens, cache-hit rate if available, retries, latency, error rate, and cost per successful task. Freeze a quality evaluation set.

Week 2: route one workload. Change base_url and api_key in one service. Keep the old path behind a flag. Send a small slice of traffic to the new route, replay the evaluation set, and compare quality, tokens, and cost.

Week 3: add cache and output limits. Move stable instructions to the front, define JSON schemas, set max_tokens by task, and check whether output tokens fall without a quality loss.

Week 4: expand and set guardrails. Add per-project keys, budget alerts, fallback models, and a weekly cost review. Remove the old path only after the new one has survived a full traffic cycle.

Checklist

  • One routing table per product surface
  • Cacheable prefix separated from variable input
  • max_tokens and stop conditions set per task
  • Non-urgent jobs scheduled outside interactive peaks
  • Retry budget and fallback route defined
  • Cost per successful task on a dashboard
  • Pricing page checked before each budget cycle

Prices and model catalogs change. The DeepSeek and Doubao rates in this guide are a snapshot from November 17, 2026; confirm the current rate at tokuse.com/pricing. For Kimi, GLM, Claude, and GPT, use the live catalog price. Keep your evaluation set fixed so a cheaper route is also a defensible one.

Top comments (0)