MCPcopy
hub / github.com/claude-code-best/claude-code / getModelCosts

Function getModelCosts

src/utils/modelCost.ts:144–164  ·  view source on GitHub ↗
(model: string, usage: Usage)

Source from the content-addressed store, hash-verified

142}
143
144export function getModelCosts(model: string, usage: Usage): ModelCosts {
145 const shortName = getCanonicalName(model)
146
147 // Check if this is an Opus 4.6 model with fast mode active.
148 if (
149 shortName === firstPartyNameToCanonical(CLAUDE_OPUS_4_6_CONFIG.firstParty)
150 ) {
151 const isFastMode = usage.speed === 'fast'
152 return getOpus46CostTier(isFastMode)
153 }
154
155 const costs = MODEL_COSTS[shortName]
156 if (!costs) {
157 trackUnknownModelCost(model, shortName)
158 return (
159 MODEL_COSTS[getCanonicalName(getDefaultMainLoopModelSetting())] ??
160 DEFAULT_UNKNOWN_MODEL_COST
161 )
162 }
163 return costs
164}
165
166function trackUnknownModelCost(model: string, shortName: ModelShortName): void {
167 logEvent('tengu_unknown_model_cost', {

Callers 1

calculateUSDCostFunction · 0.85

Calls 5

getCanonicalNameFunction · 0.85
getOpus46CostTierFunction · 0.85
trackUnknownModelCostFunction · 0.85

Tested by

no test coverage detected