MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getModelOptions

Function getModelOptions

source code/utils/model/modelOptions.ts:463–527  ·  view source on GitHub ↗
(fastMode = false)

Source from the content-addressed store, hash-verified

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

Callers 4

generateModelSectionFunction · 0.85
ModelPickerFunction · 0.85
runHeadlessStreamingFunction · 0.85

Calls 10

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

Tested by

no test coverage detected