← Station

Normalizing Model IDs Across Four AI Providers

BLIP · · Engineering · 1 min read

Claude Code, Codex, OpenCode, Kimi all spell the same model differently. One alias map collapses them.

Kharcha aggregates AI-coding-tool usage from four sources — Claude Code’s JSONL files, Codex’s SQLite + JSONL, OpenCode’s local store, and a Kimi exporter. All of them log “the same model” with different identifiers.

GitHub Copilot calls it github-copilot:claude-opus-4.6. Vercel calls it vercel/anthropic/claude-opus-4-6. OpenCode might pass opencode:claude-3-5-sonnet. Anthropic’s API itself uses claude-opus-4-6. If you don’t normalize at ingest, your dashboard double-counts the same model under three different labels.

The normalizer is twenty lines:

const WRAPPED_CLAUDE_PROVIDERS = new Set(["github-copilot", "vercel", "opencode"]);

export function normalizeModelKey(provider: string, model: string): NormalizedModelKey {
  if (WRAPPED_CLAUDE_PROVIDERS.has(provider)) {
    const wrappedModel = model.includes("/") ? model.split("/").pop() ?? model : model;
    if (wrappedModel.startsWith("claude-")) {
      return {
        provider: "anthropic",
        model: wrappedModel.replace(/\.6$/u, "-6"),
      };
    }
  }
  return { provider, model };
}

Two rules. If the provider is a known Claude wrapper, strip the path prefix and re-attribute to anthropic. Replace the trailing .6 (Anthropic’s older shorthand) with -6 (their canonical form). Everything else passes through.

This sits at the front of the sync pipeline, so every row entering the database is already canonicalized. Pricing snapshots are keyed off the normalized identifier, which means the same model gets the same cost lookup regardless of which CLI logged it.

It’s a tiny module — packages/usage-core/src/model-aliases.ts — but it’s the difference between a dashboard that shows “Claude Opus 4.6” once and one that shows it three times under different vendor names.

// Discussion

Comments are powered by GitHub Discussions via Giscus. Sign in with your GitHub account to add a reply, or discuss on X.

Keyboard Shortcuts

// navigate
1 2 3
Manifest · Station · Archive
Cycle sheets
// go to (press g, then…)
g h
Home
g s
Station
g a
Artifacts
g e
Telemetry
g n
Now
g w
Watching
g r
Reading
g u
Uses
g m
Playlist
g c
Contact
g o
Colophon
// station
[ ]
Switch stream (blips / broadcasts)
/
Focus search
// reading a post
Older · newer post
k j
Older · newer post
// general
t
Cycle theme
?
Toggle this panel
Esc
Close panel