diff --git a/src/models.ts b/src/models.ts index 6eb6c05f..4d65a288 100644 --- a/src/models.ts +++ b/src/models.ts @@ -641,6 +641,16 @@ export function getModelCosts(model: string): ModelCosts | null { if (pricingCache.has(canonical)) return pricingCache.get(canonical)! + // Gateway ids such as cp/cline-pass/glm-5.3 survive one prefix strip as + // cline-pass/glm-5.3. Price the last path segment through the same aliases + // getShortModelName already uses for the label. + if (canonical.includes('/')) { + const segment = canonical.slice(canonical.lastIndexOf('/') + 1) + const aliasedSegment = resolveAlias(segment) + if (pricingCache.has(aliasedSegment)) return pricingCache.get(aliasedSegment)! + if (pricingCache.has(segment)) return pricingCache.get(segment)! + } + const prefixOverride = getPriceOverridePrefix(canonical) if (prefixOverride) return prefixOverride diff --git a/tests/models.test.ts b/tests/models.test.ts index f16c769f..6ab0fba0 100644 --- a/tests/models.test.ts +++ b/tests/models.test.ts @@ -69,6 +69,8 @@ describe('getModelCosts', () => { expect(sibling).not.toBeNull() expect(lower!.inputCostPerToken).toBe(sibling!.inputCostPerToken) expect(upper!.outputCostPerToken).toBe(sibling!.outputCostPerToken) + expect(getModelCosts('cp/cline-pass/glm-5.3')!.inputCostPerToken).toBe(sibling!.inputCostPerToken) + expect(getModelCosts('omniroute:cp/cline-pass/glm-5.3')!.inputCostPerToken).toBe(sibling!.inputCostPerToken) }) })