Overview
Concrete tool for normalizing free-text model labels from telemetry events to canonical model IDs for pricing lookup, provided by the telemetry worker.
Description
The normalizeLabel function takes a model label as seen in telemetry (e.g., cc/claude-opus-5-5(high)) and returns a prioritized list of candidate canonical IDs by stripping jcode suffixes, reasoning-effort markers, route prefixes, and gateway prefixes. The candidates are checked against the models.dev catalog in order, most literal first. The syncModelPrices function fetches the catalog and populates the D1 model_prices table.
Usage
- Normalize a label: Call
normalizeLabel(label) to get candidate IDs.
- Sync prices: Call
syncModelPrices(env) on nightly cron to populate prices.
Code Reference
Source Location
- Repository: jcode
- File: telemetry-worker/src/model-pricing.js
Signature
export const CATALOG_URL = "https://models.dev/api.json";
export const CACHE_INCLUSIVE_PROVIDERS = new Set([...]);
export function normalizeLabel(label) -> string[]
// In worker.js:
async function syncModelPrices(env)
Import
import { normalizeLabel, CATALOG_URL, CACHE_INCLUSIVE_PROVIDERS } from "./model-pricing.js";
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| label |
string |
Yes /// Telemetry model label (e.g., "cc/claude-opus-5-5(high)")
|
Outputs
| Name |
Type |
Description
|
| return |
string[] /// Candidate canonical model IDs in priority order
|
Usage Examples
Normalize a Label
import { normalizeLabel } from "./model-pricing.js";
const candidates = normalizeLabel("cc/claude-opus-5-5(high)");
// Returns: ["claude-opus-5-5", "claude-opus-5-5-5", ...]
const candidates = normalizeLabel("anthropic-oauth:opus-5-5");
// Returns: ["anthropic-oauth:opus-5-5", "opus-5-5"]
Related Pages
Implements Principle
Requires Environment
Uses Heuristics
Page Connections
Double-click a node to navigate. Hold to expand connections.