Principle:1jehuang Jcode Model Price Sync
| Knowledge Sources | |
|---|---|
| Domains | Telemetry, Data_Normalization |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
A normalization pipeline that maps free-text model labels from telemetry events to canonical model IDs in a catalog, resolving route prefixes, gateway aliases, and effort suffixes to match per-model pricing data.
Description
Model price sync is the process of resolving the many ways users reference a model (through different gateways, route prefixes, and effort suffixes) to a single canonical model ID in a pricing catalog. For example, cc/claude-opus-5-5(high), anthropic-oauth:opus-5-5, and claude-opus-5-5-xhigh all refer to the same model. The normalization function strips prefixes and suffixes to produce candidate IDs, which are then matched against the catalog.
The problem solved is unpriced traffic in spend dashboards: when a new model is released, its telemetry label doesn't match any catalog entry, so it's priced at $0. Spend appears to drop while real usage is flat. By running the same normalization matcher nightly (not just manually), newly observed labels get priced without anyone remembering to sync.
The design includes cache-inclusive provider handling: some providers report cached tokens as a subset of input tokens, so pricing them separately would double-bill. The CACHE_INCLUSIVE_PROVIDERS set marks these providers for special handling.
Usage
Use this principle when a telemetry or analytics system needs to match free-text model references to a pricing catalog. The trigger is: "model labels arrive from multiple gateways with inconsistent naming, and spend dashboards need accurate per-model pricing." It is appropriate for: cost dashboards, budget alerts, and model usage analysis.
Theoretical Basis
The normalization pipeline has three stages:
- Strip: Remove jcode-specific suffixes (
[1m],[web]), parenthesized reasoning effort ((high)), trailing@Providerdisambiguators, and effort suffixes (-xhigh,-high). - Expand: Generate candidate IDs by splitting on route prefixes (
provider:model), gateway prefixes (cc/,oc/,nvidia/), and aliases (codex-auto-review→gpt-5.3-codex). - Match: Look up each candidate in the models.dev catalog, in priority order (most literal first). If matched, store the per-model input/output/cache pricing in the
model_pricesD1 table.
Pseudo-code logic:
# Abstract algorithm (NOT real implementation)
def normalize_label(label):
s = label.strip()
# Strip jcode suffixes
s = s.replace("[1m]", "").replace("[web]", "")
s = strip_effort_parenthesis(s)
s = strip_trailing_provider(s)
s = strip_effort_suffix(s)
candidates = {s}
# Expand route prefixes
if ":" in s:
candidates.add(s.split(":", 1)[1])
# Expand gateway prefixes
for c in list(candidates):
if "/" in c:
candidates.add(c.split("/", 1)[1])
# Check aliases
alias = LABEL_ALIASES.get(s.lower())
if alias:
return [alias]
return list(candidates) # priority order
def sync_prices(catalog_url):
catalog = fetch(catalog_url)
for label in observed_labels:
candidates = normalize_label(label)
for candidate in candidates:
if candidate in catalog:
store_price(label, catalog[candidate])
break