claude-code - 💡(How to fix) Fix [BUG] CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var failing edge case

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Setting the CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var to 1, we expect that Claude Code will fetch models from gateway’s /v1/models endpoint. However, if CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC is set to any value, this model discovery doesn't work and no requests are made to the gateway. In order to make this work, the CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC env var must be completely unset (setting to 0 does not suffice).

Moreover, setting the env var CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 is supposedly equivalent to setting DISABLE_AUTOUPDATER=1 DISABLE_FEEDBACK_COMMAND=1 DISABLE_ERROR_REPORTING=1 DISABLE_TELEMETRY=1, according to the docs, but when these are set, the request to /v1/models is actually made.

What Should Happen?

Setting the CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var to 1, we expect that Claude Code will fetch models from gateway’s /v1/models endpoint.

Error Messages/Logs

N/A

Steps to Reproduce

  1. Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var to 1.
  2. Set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC env var to 1.
  3. Use an Anthropic-compatible gateway and set ANTHROPIC_BASE_URL env var.
  4. Add some custom models to the /v1/models endpoint of the gateway, ensure it's an Anthropic model for it to be surfaced in Claude Code.
  5. Run Claude Code, execute the /model slash command.
  6. The model you added will be missing here.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.131

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Windows Terminal

Additional Information

I tested this by tracking the requests outgoing from Claude Code to the gateway's /v1/models endpoint to be extra sure no outgoing request was being made.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var failing edge case