From 7d0999ed5cdbd3c4f2fefd81480aa28f70770a84 Mon Sep 17 00:00:00 2001 From: mkusaka Date: Sat, 17 Jan 2026 19:18:44 +0900 Subject: [PATCH] fix(opencode): add model aliases for GitHub Copilot model names 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 --- apps/opencode/src/cost-utils.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/opencode/src/cost-utils.ts b/apps/opencode/src/cost-utils.ts index 58f2850f..69dd5e8f 100644 --- a/apps/opencode/src/cost-utils.ts +++ b/apps/opencode/src/cost-utils.ts @@ -5,8 +5,28 @@ import { Result } from '@praha/byethrow'; /** * Model aliases for OpenCode-specific model names that don't exist in LiteLLM. * Maps OpenCode model names to their LiteLLM equivalents for pricing lookup. + * + * GitHub Copilot uses dot notation (e.g., claude-opus-4.5) while LiteLLM uses + * hyphen notation (e.g., claude-opus-4-5). This mapping handles those differences. + * + * GitHub Copilot model names are sourced from: https://models.dev/api.json */ const MODEL_ALIASES: Record = { + // GitHub Copilot uses dots, LiteLLM uses hyphens for Claude 4.5 models + 'claude-opus-4.5': 'claude-opus-4-5', + 'claude-sonnet-4.5': 'claude-sonnet-4-5', + 'claude-haiku-4.5': 'claude-haiku-4-5', + // GitHub Copilot shorthand names for Claude 4 models + 'claude-opus-4': 'claude-opus-4-20250514', + 'claude-opus-41': 'claude-opus-4-1', + 'claude-sonnet-4': 'claude-sonnet-4-20250514', + // GitHub Copilot Claude 3.x model names + 'claude-3.5-sonnet': 'claude-3-5-sonnet-latest', + 'claude-3.7-sonnet': 'claude-3-7-sonnet-latest', + // Extended thinking variant uses same pricing as base model + 'claude-3.7-sonnet-thought': 'claude-3-7-sonnet-latest', + // Grok models require provider prefix + 'grok-code-fast-1': 'xai/grok-code-fast-1', // OpenCode uses -high suffix for higher tier/thinking mode variants 'gemini-3-pro-high': 'gemini-3-pro-preview', };