Skip to content

Conversation

@mkusaka
Copy link
Contributor

@mkusaka mkusaka commented Jan 17, 2026

Summary

  • map GitHub Copilot model names (dot notation) to LiteLLM pricing IDs
  • ensure cost calculations resolve for Copilot logs where cost is 0
  • keep existing behavior for other providers unchanged

Context

Before/After

  • Ran locally to validate the output: 2026-01-15 ran with OpenCode zen, 2026-01-16+ ran with GitHub Copilot subscription using Opus 4.5

Before

📊 OpenCode Token Usage Report - Daily

┌──────────┬─────────────────────────────────────────────────┬──────────┬──────────┬───────────┬──────────┬───────────┬──────────┐
│ Date     │ Models                                          │    Input │   Output │     Cache │    Cache │     Total │     Cost │
│          │                                                 │          │          │    Create │     Read │    Tokens │    (USD) │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - big-pickle                                    │   14,733 │       18 │         0 │      448 │    15,199 │    $0.00 │
│ 01-10    │                                                 │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - gpt-5.1-codex-max                             │  573,996 │   60,889 │    56,491 │ 3,780,2… │ 4,471,581 │    $2.30 │
│ 01-14    │ - sonnet-4-5                                    │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - claude-opus-4.5                               │  667,177 │  133,670 │   947,302 │ 23,721,… │ 25,469,9… │   $17.80 │
│ 01-15    │ - claude-sonnet-4.5                             │          │          │           │          │           │          │
│          │ - gpt-5.1-codex-max                             │          │          │           │          │           │          │
│          │ - opus-4-5                                      │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - claude-opus-4.5                               │ 2,294,1… │  189,483 │         0 │ 27,108,… │ 29,591,6… │    $0.00 │
│ 01-16    │                                                 │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - claude-opus-4.5                               │ 7,607,0… │  659,903 │         0 │ 180,860… │ 189,127,… │   $40.67 │
│ 01-17    │ - gpt-5.2-codex                                 │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ Total    │                                                 │ 11,157,… │ 1,043,9… │ 1,003,793 │ 235,470… │ 248,675,… │   $60.78 │
└──────────┴─────────────────────────────────────────────────┴──────────┴──────────┴───────────┴──────────┴───────────┴──────────┘

After

📊 OpenCode Token Usage Report - Daily

┌──────────┬─────────────────────────────────────────────────┬──────────┬──────────┬───────────┬──────────┬───────────┬──────────┐
│ Date     │ Models                                          │    Input │   Output │     Cache │    Cache │     Total │     Cost │
│          │                                                 │          │          │    Create │     Read │    Tokens │    (USD) │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - big-pickle                                    │   14,733 │       18 │         0 │      448 │    15,199 │    $0.00 │
│ 01-10    │                                                 │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - gpt-5.1-codex-max                             │  573,996 │   60,889 │    56,491 │ 3,780,2… │ 4,471,581 │    $2.30 │
│ 01-14    │ - sonnet-4-5                                    │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - claude-opus-4.5                               │  667,177 │  133,670 │   947,302 │ 23,721,… │ 25,469,9… │   $20.76 │
│ 01-15    │ - claude-sonnet-4.5                             │          │          │           │          │           │          │
│          │ - gpt-5.1-codex-max                             │          │          │           │          │           │          │
│          │ - opus-4-5                                      │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - claude-opus-4.5                               │ 2,294,1… │  189,483 │         0 │ 27,108,… │ 29,591,6… │   $29.76 │
│ 01-16    │                                                 │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ 2026     │ - claude-opus-4.5                               │ 7,607,0… │  659,903 │         0 │ 180,860… │ 189,127,… │   $75.86 │
│ 01-17    │ - gpt-5.2-codex                                 │          │          │           │          │           │          │
├──────────┼─────────────────────────────────────────────────┼──────────┼──────────┼───────────┼──────────┼───────────┼──────────┤
│ Total    │                                                 │ 11,157,… │ 1,043,9… │ 1,003,793 │ 235,470… │ 248,675,… │  $128.68 │
└──────────┴─────────────────────────────────────────────────┴──────────┴──────────┴───────────┴──────────┴───────────┴──────────┘

Closes

Summary by CodeRabbit

  • New Features
    • Expanded AI model support for cost calculations, now including Claude 4.5, 4.x, 3.x Sonnet variants, Grok models, OpenCode high-tier variants, and Gemini 3 Pro.
    • Enhanced model name resolution system to accurately translate between naming conventions for consistent pricing lookups.

✏️ Tip: You can customize this high-level summary in your review settings.

GitHub Copilot uses different model naming conventions that don't match
LiteLLM's pricing database:
- Dots instead of hyphens (claude-opus-4.5 vs claude-opus-4-5)
- Shorthand names (claude-opus-4 vs claude-opus-4-20250514)
- Extended thinking variants (claude-3.7-sonnet-thought)
- Provider-prefixed names (grok-code-fast-1 vs xai/grok-code-fast-1)

This caused costs to show as $0.00 when using GitHub Copilot subscription
because the model names couldn't be found in LiteLLM's pricing data.

Model names were sourced from:
- https://models.dev/api.json (github-copilot provider models)

Added mappings for:
- Claude 4.5 models (opus, sonnet, haiku)
- Claude 4 shorthand names
- Claude 3.x models (3.5-sonnet, 3.7-sonnet, 3.7-sonnet-thought)
- Grok models
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Added a MODEL_ALIASES map to cost-utils.ts that translates GitHub Copilot's dot-notation model names (e.g., claude.4.5) to LiteLLM-compatible hyphen-notation (e.g., claude-sonnet-4.5) for accurate pricing lookups across Claude, Grok, OpenCode, and Gemini variants.

Changes

Cohort / File(s) Summary
Model Alias Mapping
apps/opencode/src/cost-utils.ts
Added 20 lines introducing MODEL_ALIASES constant with mappings for Claude 4.5/4.x variants, Claude 3.x sonnet variants, Grok models with provider prefixes, OpenCode high-tier variants, and Gemini 3 Pro high; consumed by resolveModelName() and calculateCostForEntry() for cost calculation

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • PR #743: Expands isClaudeModel to detect anthropic.claude-/* prefixes, complementing this PR's alias-based normalization for Claude model name variations.

Suggested reviewers

  • ryoppippi

Poem

🐰 A map of names, dot-dots to dashes,
Aliases spark like quick lightning flashes!
From Claude to Grok, the prices align,
No more zero costs—now pricing feels fine! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(opencode): add model aliases for GitHub Copilot model names' clearly and specifically describes the main change—adding model aliases for GitHub Copilot naming conventions to resolve pricing lookups.
Linked Issues check ✅ Passed The pull request implements the primary objective from issue #802: adding aliases to map GitHub Copilot model names (dot notation, provider prefixes, shorthand) to LiteLLM pricing identifiers to resolve missing cost calculations.
Out of Scope Changes check ✅ Passed All changes are strictly focused on adding the MODEL_ALIASES map in cost-utils.ts to resolve GitHub Copilot model naming issues; no unrelated code modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add alias for github copilot model names

2 participants