Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1jehuang Jcode Model Price Sync

From Leeroopedia
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:

  1. Strip: Remove jcode-specific suffixes ([1m], [web]), parenthesized reasoning effort ((high)), trailing @Provider disambiguators, and effort suffixes (-xhigh, -high).
  2. 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).
  3. 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_prices D1 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

Related Pages

Implemented By

Uses Heuristics

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment