Skip to content

All posts

AI

How to restrict which Claude models developers can use in Claude Code

Ritesh Patel

AI: How to restrict which Claude models developers can use in Claude Code

To restrict which Claude models developers can use in Claude Code, set an availableModels list in managed settings. Entries can be family aliases such as sonnet or model IDs. Add deniedModels to block one release, and set enforceAvailableModels to true so the Default option can’t resolve to a model outside the list.

Checked against the Claude Code settings reference and the model configuration page, both fetched on 2026-11-29. The pages give a minimum Claude Code version for each key (v2.1.175, v2.1.205 and v2.1.283), but they don’t name one release for the whole feature. Confirm the behavior on the release your developers run.

Allow a list of models with availableModels

availableModels takes an array of model aliases or model IDs. Each entry matches a model family such as sonnet, a version prefix such as claude-sonnet-4-5, or a full model ID such as claude-sonnet-4-5-20250929. When the key is unset, every model is available. The key is read from any settings file, but it applies as an organization rule only when you deploy it in managed settings.

{
  "availableModels": ["sonnet", "haiku"]
}

Once managed settings define the list, that list applies as written. Entries in user, project or local settings can’t extend it. Two details catch teams out. First, a specific model entry turns off the wildcard for its family in the same list. With ["sonnet", "claude-sonnet-4-5"], developers can pick only the model IDs that claude-sonnet-4-5 matches, not every Sonnet model.

Second, aliases follow the list on the Anthropic API and Claude Platform on AWS. With ["sonnet", "claude-opus-4-6"], both /model opus and --model opus select Claude Opus 4.6, the newest permitted Opus. Claude Code shows a notice that names both models. Before v2.1.205, an alias whose newest version sat outside the list was rejected or replaced like any other blocked selection, even when the list allowed an older version.

Match new releases with availableModelsMatch

By default, a model ID entry also permits later versions that extend it. An entry of claude-opus-5 permits Opus 5.5 as soon as Claude Code supports it. Set availableModelsMatch to "exact" when each release should need a deliberate decision. Each model ID entry then permits only the version it names, and a newer release stays blocked until you add it.

Case Default prefix exact
Entry claude-opus-5, model Opus 5 Permitted Permitted
Entry claude-opus-5, model Opus 5.5 Permitted Blocked until listed

The key is managed-only. Claude Code ignores it in user, project and local settings and in --settings, with a warning, and it needs v2.1.283 or later. The Default option is also limited to the listed models whenever the list names at least one model or family.

{
  "availableModels": ["claude-opus-5", "claude-sonnet-5"],
  "availableModelsMatch": "exact"
}

Block one release with deniedModels

deniedModels blocks models even when availableModels permits them. It also works with no allowlist at all. Matching depends on the entry: a family alias blocks the whole family, and a full model ID blocks that version in every spelling, including dated and provider-specific IDs.

{
  "availableModels": ["opus", "sonnet"],
  "deniedModels": ["claude-opus-5-5"]
}

This example permits Opus and Sonnet and blocks Opus 5.5. A release that no entry blocks stays permitted. The key is managed-only, like availableModelsMatch, and it needs v2.1.283 or later. The model page says earlier versions ignore both keys, so also set requiredMinimumVersion to v2.1.283 or later. That keeps older versions from starting on this policy.

Stop the Default option from escaping the list

The /model picker has a Default option, which resolves to the model your account type uses. With prefix matching, availableModels on its own leaves that resolution alone, so Default can still run a model outside your list. Set enforceAvailableModels to true in managed settings, next to a non-empty availableModels, and Claude Code resolves Default to the first list entry that names an allowed, available model. The key needs v2.1.175 or later.

{
  "availableModels": ["sonnet", "haiku"],
  "enforceAvailableModels": true
}

Once your organization deploys any managed settings, Claude Code reads this key from the managed source alone and ignores it in other files. Enforcement is skipped if no entry resolves to an allowed, available model. Claude Code then shows a warning, visible only under --debug. Keep at least one entry you know is available.

When Default would resolve to a blocked model

A blocked default counts as a model outside a non-empty availableModels list. If you don’t set that list, Claude Code steps the Default option down in this order until it finds a permitted model:

  1. The newest permitted version of the same family.
  2. The first availableModels entry that names a permitted model.

If none of those is permitted, a session that starts on Default refuses to start, and the error names the key to fix.

Set the restriction in managed settings

  1. Decide the list. Family aliases follow new releases automatically. Full model IDs with availableModelsMatch set to "exact" hold each release until you add it.
  2. Add availableModels to your managed settings file. Deliver it with the same tools you use for managed settings. The managed settings guide for enterprises covers file locations and MDM delivery.
  3. Add enforceAvailableModels: true in the same managed source. The model page says to deploy the pair together in the highest-ranked managed source you deliver, because a pair in a lower source is ignored when another managed source is delivered.
  4. Add deniedModels or availableModelsMatch only when every machine runs v2.1.283 or later, and set requiredMinimumVersion to match.
  5. Test on a machine with the policy loaded. Open /model and check the list. Then run /model with a blocked name and confirm that Claude Code rejects it.

What a blocked model does in a session

The docs describe a different result for each place a model can be set. Use this table to predict what a developer sees.

Where the model is set What Claude Code does
/model Rejects the switch with an error
--model flag, ANTHROPIC_MODEL or the model setting Replaces the value at startup with a warning, and the session starts on the default model
Subagent or teammate override Runs on a fallback model rather than failing the request
Skill or command override Ignores the override and runs on the session model
CLAUDE_CODE_AUTO_MODE_MODEL Ignores the variable and picks the auto mode classifier model as if it were unset

A blocked subagent override runs on a fallback model rather than failing the request, so review the subagents in your restricted-tools guide after you change the list.

Enforcing this with AIControls

This allowlist is a Claude Code setting. It applies on machines where Claude Code reads your managed settings, and it doesn’t replace a policy point in front of model traffic. AIControls supports Claude Code through the gateway, in the CLI and in VS Code. This post doesn’t claim that the gateway restricts model choice. Deploy the managed keys above with your other Claude Code controls, and read the governance for AI coding agents pillar for how the controls fit together. For the settings order that decides which file wins, read Claude Code settings precedence.

Frequently asked questions

What happens when a developer starts Claude Code with a model that the list blocks?

It depends on where the model is set. The /model command rejects the switch with an error. A blocked value in the --model flag, the ANTHROPIC_MODEL variable or the model setting is replaced at startup with a warning that names both models, and the session starts on the default model. The docs also say that a blocked skill or command override is ignored, and the skill or command runs on the session model.

Why does a developer still get a model outside my list when I set availableModels?

With the default prefix matching, availableModels alone leaves the Default option on the system's runtime default for the account. That model can sit outside the list. Set enforceAvailableModels to true next to a non-empty list in managed settings, so the Default option is kept inside the list.

Can a developer add a model to the list in their own settings file?

Not when managed settings define availableModels. The docs say the managed list applies alone, and entries in user, project or local settings cannot extend it. Before Claude Code v2.1.175, entries from lower-precedence scopes merged into the managed list instead of being replaced by it, so check the version on every machine before you rely on the list.

If I deny claude-opus-5-5, does Opus 5 stay available?

Yes. A full model ID such as claude-opus-5-5 blocks only that version. In availableModels, a model ID with no minor version, such as claude-opus-5, also permits later releases such as Opus 5.5. A deniedModels entry for a full model ID blocks only that version, so deny claude-opus-5-5 to block Opus 5.5. The deniedModels key needs Claude Code v2.1.283 or later.

Ritesh Patel, Founder & VP Product, Nirmata

Ritesh Patel is a founder of Nirmata and leads its products. He writes about governing AI coding agents, MCP security and Kubernetes policy as code.

LinkedIn

Govern AI agents with AIControlsControl what AI agents do, and prove it.
Share

Stay up-to-date with the latest in AI, governance, and infrastructure

Subscribe to our free monthly newsletter to get industry news, DevOps tips, and articles right to your inbox on Kyverno, containerization, Kubernetes deployment & management and more.