Cost Governance - Aug 19, 2026

Cache-Aware Chinese AI API Ledger for DeepSeek, Qwen, Kimi, and GLM

Design a cache-aware usage ledger that compares DeepSeek, Qwen, Kimi, and GLM routes with dated price rows and task-level controls.

Target markets: United States, United Kingdom, Canada, Australia, Germany, France, JapanCache ledgerOpenAI-compatible

Keyword source: AIWave Daily Keyword Intelligence for 2026-08-19. Current GSC retrieval failed, so this article uses the report's public market research and the latest successful Tier 1/2 context without fabricating Search Console rows.

The Ledger Problem

The Aug 19 keyword report grouped Qwen, GLM, Kimi, DeepSeek, Chinese AI API, and OpenAI-compatible migration into the same market context. That is the right grouping for a SaaS team. Buyers do not want one more isolated model page. They want a way to compare families under the same operational accounting rules. A cache-aware ledger is the foundation for that comparison.

The official public rows checked on Aug 19, 2026 show why a simple token total is not enough. Kimi K3's public page lists $3.00 per 1M cache-miss input tokens, $0.30 per 1M cache-hit input tokens, and $15.00 per 1M output tokens. Z.AI's GLM pricing page lists GLM-5.2 and GLM-5.1 at $1.40 per 1M input tokens, $0.26 per 1M cached input tokens, and $4.40 per 1M output tokens. QwenCloud documents pay-as-you-go pricing, context-tiered billing, context caching, thinking-token billing, Batch API behavior, and tool fees. DeepSeek's current docs and marketplace rows add peak-window complexity.

A ledger should therefore store token categories, not just token totals. At minimum, keep input_tokens, cached_input_tokens, cache_miss_input_tokens, output_tokens, thinking_tokens when exposed, tool_units when exposed, model_id, provider, route_reason, price_source_date, and effective_usd. If a provider does not expose a category, store unknown and document the limitation. This is more honest than forcing every model into one artificial schema.

Dated Price Map

The table below is not a universal ranking. It is a dated map of rows that matter for ledger design. The point is to decide which fields the ledger must capture before a team launches volume traffic.

FamilyPublic row checked Aug 19 2026Input field to trackOutput field to trackSpecial ledger fieldBest-fit workload
DeepSeek V4Official docs plus AIWave unified planning rowscache miss and cache hitoutput tokenspeak_window or unified_policyAgent planning, reasoning, execution split
Kimi K3$3.00 miss, $0.30 hit, $15.00 outputstable-prefix cache hitlong response outputcache_prefix_hashLong-context repository and knowledge tasks
GLM-5.2 / GLM-5.1$1.40 input, $0.26 cached input, $4.40 outputcached inputoutput tokenstool_or_agent_fee when usedReasoning-tier routing and tool workflows
QwenCloudContext-tiered pay-as-you-go docscontext tier and cached inputoutput and thinking tokensbatch_discount_flag and tool_feeCoding, batch jobs, and context-sensitive tasks
AIWave account routeLive model catalog and pricing pagenormalized route fieldsnormalized route fieldsroute_reasonOne-key Chinese model switching

A useful ledger lets finance ask, why did cost change this week, and lets engineering answer with data. Did output length grow? Did cache-hit share fall? Did traffic move from Flash to Pro? Did a Qwen task enter a higher context tier? Did a tool fee start appearing? Those are different root causes, and each requires a different fix.

Do not treat cache as a background optimization. Cache behavior is a product-control surface. A stable prompt prefix can turn a repeated repository summary into a cheaper input category. A nondeterministic prompt builder can destroy that benefit by changing the prefix every request. That is why cache_prefix_hash is a real ledger field, not an implementation detail.

Ledger Schema

The schema below is intentionally small. It can live in Postgres, BigQuery, ClickHouse, a warehouse table, or a signed CSV export. The important part is that every row is tied to the route decision and the price source date.

from dataclasses import dataclass, asdict
from datetime import datetime, timezone
from decimal import Decimal
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY_HERE",
    base_url="https://aiwave.live/v1",
)

@dataclass
class LedgerRow:
    workspace_id: str
    model_id: str
    provider_policy: str
    route_reason: str
    price_source_date: str
    input_tokens: int | None
    cached_input_tokens: int | None
    output_tokens: int | None
    max_tokens: int
    estimated_ceiling_usd: Decimal
    started_at: str

row = LedgerRow(
    workspace_id="acme-prod",
    model_id="kimi-k3",
    provider_policy="aiwave_openai_compatible",
    route_reason="long_context_architecture_review",
    price_source_date="2026-08-19",
    input_tokens=None,
    cached_input_tokens=None,
    output_tokens=None,
    max_tokens=4800,
    estimated_ceiling_usd=Decimal("0.12"),
    started_at=datetime.now(timezone.utc).isoformat(),
)

response = client.chat.completions.create(
    model=row.model_id,
    messages=[{"role": "user", "content": "Review this repository map and list the billing-risk modules."}],
    max_tokens=row.max_tokens,
)

print({"response_id": response.id, "ledger": asdict(row)})

The actual token fields may be populated after the response, depending on the usage object returned by the route. If cached tokens or thinking tokens are unavailable, leave them null and mark the row as partial. Do not backfill a guessed cache-hit number. Guessing makes dashboards look clean while making cost analysis unreliable.

The code uses `YOUR_API_KEY_HERE` so it can be pasted safely into documentation. In production, load the key from a secret manager and redact workspace identifiers in shared logs. The ledger should store enough to analyze cost without retaining user prompts, customer documents, or credentials.

Route Diagnostics

A weekly cost review should start with four charts. First, spend by model family and route_reason. Second, output_tokens by task kind. Third, cached_input_tokens divided by total eligible input. Fourth, error and retry counts by provider policy. Those charts quickly separate quality-driven cost from waste.

If spend rises because output_tokens increased, tighten max_tokens and improve response templates. If spend rises because cache-hit share fell, inspect prompt prefix stability. If spend rises because more tasks moved to Pro, review route thresholds and high-risk labels. If spend rises because retries increased, inspect 429 handling and provider capacity before changing model policy.

Qwen deserves special care because public docs describe context-tiered billing, Batch API behavior, thinking-token billing, and tool fees. A Qwen row should record context tier and whether batch processing was used. GLM rows should record cached input and tool or agent feature use when those features apply. Kimi rows should record stable-prefix hash and long-context task type. DeepSeek rows should record peak-window or unified-policy interpretation.

The ledger also supports Tier 1 compliance conversations. A UK or German buyer may ask how costs are calculated, where logs are stored, and whether sensitive prompts are retained. A good answer can separate billing metadata from content retention. That clarity is more credible than broad assurances, especially for enterprise developers evaluating Chinese model access.

Implementation Checklist

Start with one route-policy table and one usage-ledger table. The route-policy table owns model selection. The ledger table records what happened. Do not let prompt text choose financial policy. Route policy should be deterministic enough for a code review and flexible enough for product managers to set ceilings by workspace, environment, and task kind.

Add a price-card table with source_url, source_date, model_id, currency, input row, output row, cache row, schedule policy, and notes. When a provider changes a row, insert a new record. Do not overwrite history. Old rows explain prior decisions and make invoice review possible.

Connect every cost-governance article to the AIWave docs, model catalog, and pricing page. The Aug 19 report called out stronger internal links as an action item, and ledger content is a natural bridge. A reader looking for `qwen api`, `glm api`, or `kimi api pricing` should see how a model row becomes an actual production route.

External sources checked

Related AIWave guides

FAQ

Why does a Chinese AI API ledger need cache fields?

Cache-hit and cache-miss input can have very different unit economics, so a plain total-token field hides the real driver of spend.

Which official public rows were checked for this ledger?

The Aug 19 review used DeepSeek pricing docs, QwenCloud pricing docs, Kimi K3 pricing, Z.AI GLM pricing, and AIWave model pages.

Can one OpenAI-compatible client log several Chinese model families?

Yes. Keep the SDK surface stable and log model_id, provider, route_reason, price_source_date, and token categories for each request.