MCPcopy
hub / github.com/codeaashu/claude-code / getModelOptions

Function getModelOptions

src/utils/model/modelOptions.ts:461–525  ·  view source on GitHub ↗
(fastMode = false)

Source from the content-addressed store, hash-verified

459}
460
461export function getModelOptions(fastMode = false): ModelOption[] {
462 const options = getModelOptionsBase(fastMode)
463
464 // Add the custom model from the ANTHROPIC_CUSTOM_MODEL_OPTION env var
465 const envCustomModel = process.env.ANTHROPIC_CUSTOM_MODEL_OPTION
466 if (
467 envCustomModel &&
468 !options.some(existing => existing.value === envCustomModel)
469 ) {
470 options.push({
471 value: envCustomModel,
472 label: process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME ?? envCustomModel,
473 description:
474 process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION ??
475 `Custom model (${envCustomModel})`,
476 })
477 }
478
479 // Append additional model options fetched during bootstrap
480 for (const opt of getGlobalConfig().additionalModelOptionsCache ?? []) {
481 if (!options.some(existing => existing.value === opt.value)) {
482 options.push(opt)
483 }
484 }
485
486 // Add custom model from either the current model value or the initial one
487 // if it is not already in the options.
488 let customModel: ModelSetting = null
489 const currentMainLoopModel = getUserSpecifiedModelSetting()
490 const initialMainLoopModel = getInitialMainLoopModel()
491 if (currentMainLoopModel !== undefined && currentMainLoopModel !== null) {
492 customModel = currentMainLoopModel
493 } else if (initialMainLoopModel !== null) {
494 customModel = initialMainLoopModel
495 }
496 if (customModel === null || options.some(opt => opt.value === customModel)) {
497 return filterModelOptionsByAllowlist(options)
498 } else if (customModel === 'opusplan') {
499 return filterModelOptionsByAllowlist([...options, getOpusPlanOption()])
500 } else if (customModel === 'opus' && getAPIProvider() === 'firstParty') {
501 return filterModelOptionsByAllowlist([
502 ...options,
503 getMaxOpusOption(fastMode),
504 ])
505 } else if (customModel === 'opus[1m]' && getAPIProvider() === 'firstParty') {
506 return filterModelOptionsByAllowlist([
507 ...options,
508 getMergedOpus1MOption(fastMode),
509 ])
510 } else {
511 // Try to show a human-readable label for known Anthropic models, with an
512 // upgrade hint if the alias now resolves to a newer version.
513 const knownOption = getKnownModelOption(customModel)
514 if (knownOption) {
515 options.push(knownOption)
516 } else {
517 options.push({
518 value: customModel,

Callers 4

generateModelSectionFunction · 0.85
ModelPickerFunction · 0.85
runHeadlessStreamingFunction · 0.85

Calls 11

getModelOptionsBaseFunction · 0.85
getGlobalConfigFunction · 0.85
getInitialMainLoopModelFunction · 0.85
getOpusPlanOptionFunction · 0.85
getAPIProviderFunction · 0.85
getMaxOpusOptionFunction · 0.85
getMergedOpus1MOptionFunction · 0.85
getKnownModelOptionFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected