MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getModelOptions

Function getModelOptions

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

Source from the content-addressed store, hash-verified

553}
554
555export function getModelOptions(fastMode = false): ModelOption[] {
556 const options = getModelOptionsBase(fastMode)
557
558 // Add the custom model from the ANTHROPIC_CUSTOM_MODEL_OPTION env var
559 const envCustomModel = process.env.ANTHROPIC_CUSTOM_MODEL_OPTION
560 if (
561 envCustomModel &&
562 !options.some(existing => existing.value === envCustomModel)
563 ) {
564 options.push({
565 value: envCustomModel,
566 label: process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME ?? envCustomModel,
567 description:
568 process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION ??
569 `Custom model (${envCustomModel})`,
570 })
571 }
572
573 // Append additional model options fetched during bootstrap
574 for (const opt of getGlobalConfig().additionalModelOptionsCache ?? []) {
575 if (!options.some(existing => existing.value === opt.value)) {
576 options.push(opt)
577 }
578 }
579
580 // Add custom model from either the current model value or the initial one
581 // if it is not already in the options.
582 let customModel: ModelSetting = null
583 const currentMainLoopModel = getUserSpecifiedModelSetting()
584 const initialMainLoopModel = getInitialMainLoopModel()
585 if (currentMainLoopModel !== undefined && currentMainLoopModel !== null) {
586 customModel = currentMainLoopModel
587 } else if (initialMainLoopModel !== null) {
588 customModel = initialMainLoopModel
589 }
590 if (customModel === null || options.some(opt => opt.value === customModel)) {
591 return filterModelOptionsByAllowlist(options)
592 } else if (customModel === 'opusplan') {
593 return filterModelOptionsByAllowlist([...options, getOpusPlanOption()])
594 } else if (customModel === 'opus' && getAPIProvider() === 'firstParty') {
595 return filterModelOptionsByAllowlist([
596 ...options,
597 getMaxOpusOption(fastMode),
598 ])
599 } else if (customModel === 'opus[1m]' && getAPIProvider() === 'firstParty') {
600 return filterModelOptionsByAllowlist([
601 ...options,
602 getMergedOpus1MOption(fastMode),
603 ])
604 } else {
605 // Try to show a human-readable label for known Anthropic models, with an
606 // upgrade hint if the alias now resolves to a newer version.
607 const knownOption = getKnownModelOption(customModel)
608 if (knownOption) {
609 options.push(knownOption)
610 } else {
611 options.push({
612 value: customModel,

Callers 5

generateModelSectionFunction · 0.85
ModelPickerFunction · 0.85
runHeadlessStreamingFunction · 0.85
createSessionFunction · 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