[BUG] CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY env var failing edge case

Resolved 💬 4 comments Opened May 21, 2026 by SipanP Closed Jun 20, 2026

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?

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.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗