[BUG] ANTHROPIC_MODEL env var does not override `model` setting in VSCode extension
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The docs at https://code.claude.com/docs/en/env-vars state:
"Where the same behavior has both an environment variable and a settings field, the environment variable takes precedence. For example, ANTHROPIC_MODEL overrides the model setting."
In the VSCode extension, ANTHROPIC_MODEL does NOT override the model key in settings.json, regardless of how the env var is set. I tested three approaches — none override model:
envblock in~/.claude/settings.json— confirmed viaprintenvthatANTHROPIC_MODELis set, butmodelwinsclaudeCode.environmentVariablesin VSCode settings — using the correct{name, value}object format per the extension's package.json schema — still doesn't overridemodel- Both simultaneously — still doesn't override
Additionally, the VSCode UI model picker writes every selection back to the model key in settings.json, and there is no /model command available in the VSCode extension (it's CLI-only). This means there is no way to make a session-only model switch without permanently changing the default for all future chats.
What Should Happen?
ANTHROPIC_MODEL set via claudeCode.environmentVariables (or the env block in settings.json) should override the model setting, as documented. Alternatively, the VSCode extension should support /model for session-only switches that don't persist to settings.json.
Error Messages/Logs
No error — the env var is silently ignored for model selection.
Confirmed ANTHROPIC_MODEL is set in the process environment:
$ printenv | grep ANTHROPIC_MODEL
ANTHROPIC_MODEL=claude-opus-4-6[1m]
Yet new chats default to whatever `model` is set to in settings.json (e.g. "haiku").
Steps to Reproduce
- In
~/.claude/settings.json, set"model": "haiku" - In the same file, set
"env": { "ANTHROPIC_MODEL": "claude-opus-4-6[1m]" } - In VSCode settings, set
"claudeCode.environmentVariables": [{ "name": "ANTHROPIC_MODEL", "value": "claude-opus-4-6[1m]" }] - Reload VSCode window (Cmd+Shift+P → "Developer: Reload Window")
- Open a new Claude Code chat
- Observe: model picker shows "Haiku", not Opus
Expected: ANTHROPIC_MODEL should override model per the docs.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.181
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
The combination means there is no way to set a persistent default model that survives UI model switches. The env var was the intended mechanism per the docs, but it doesn't work.
VSCode version: 1.100.x (macOS, Apple Silicon)
Extension: anthropic.claude-code 2.1.181-darwin-arm64