MCPcopy Index your code
hub / github.com/codeaashu/claude-code / firstPartyNameToCanonical

Function firstPartyNameToCanonical

src/utils/model/model.ts:217–270  ·  view source on GitHub ↗
(name: ModelName)

Source from the content-addressed store, hash-verified

215 * module top-level (see MODEL_COSTS in modelCost.ts).
216 */
217export function firstPartyNameToCanonical(name: ModelName): ModelShortName {
218 name = name.toLowerCase()
219 // Special cases for Claude 4+ models to differentiate versions
220 // Order matters: check more specific versions first (4-5 before 4)
221 if (name.includes('claude-opus-4-6')) {
222 return 'claude-opus-4-6'
223 }
224 if (name.includes('claude-opus-4-5')) {
225 return 'claude-opus-4-5'
226 }
227 if (name.includes('claude-opus-4-1')) {
228 return 'claude-opus-4-1'
229 }
230 if (name.includes('claude-opus-4')) {
231 return 'claude-opus-4'
232 }
233 if (name.includes('claude-sonnet-4-6')) {
234 return 'claude-sonnet-4-6'
235 }
236 if (name.includes('claude-sonnet-4-5')) {
237 return 'claude-sonnet-4-5'
238 }
239 if (name.includes('claude-sonnet-4')) {
240 return 'claude-sonnet-4'
241 }
242 if (name.includes('claude-haiku-4-5')) {
243 return 'claude-haiku-4-5'
244 }
245 // Claude 3.x models use a different naming scheme (claude-3-{family})
246 if (name.includes('claude-3-7-sonnet')) {
247 return 'claude-3-7-sonnet'
248 }
249 if (name.includes('claude-3-5-sonnet')) {
250 return 'claude-3-5-sonnet'
251 }
252 if (name.includes('claude-3-5-haiku')) {
253 return 'claude-3-5-haiku'
254 }
255 if (name.includes('claude-3-opus')) {
256 return 'claude-3-opus'
257 }
258 if (name.includes('claude-3-sonnet')) {
259 return 'claude-3-sonnet'
260 }
261 if (name.includes('claude-3-haiku')) {
262 return 'claude-3-haiku'
263 }
264 const match = name.match(/(claude-(\d+-\d+-)?\w+)/)
265 if (match && match[1]) {
266 return match[1]
267 }
268 // Fall back to the original name if no pattern matches
269 return name
270}
271
272/**
273 * Maps a full model string to a shorter canonical version that's unified across 1P and 3P providers.

Callers 3

modelCost.tsFile · 0.85
getModelCostsFunction · 0.85
getCanonicalNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected