claude-code - 💡(How to fix) Fix Gateway model discovery does not use apiKeyHelper for authentication [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#58581Fetched 2026-05-14 03:44:34
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1cross-referenced ×1

Gateway model discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1) fails silently when authentication is provided via apiKeyHelper in managed settings. The /v1/models request appears to run before the credential helper is invoked, resulting in an unauthenticated request that fails.

Root Cause

Gateway model discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1) fails silently when authentication is provided via apiKeyHelper in managed settings. The /v1/models request appears to run before the credential helper is invoked, resulting in an unauthenticated request that fails.

Fix Action

Workaround

Setting ANTHROPIC_AUTH_TOKEN statically works:

ANTHROPIC_AUTH_TOKEN=$(my-credential-helper) claude

With this, gateway models appear in the /model picker as expected.

Code Example

{
  "apiKeyHelper": "/usr/local/bin/my-credential-helper",
  "env": {
    "ANTHROPIC_BASE_URL": "https://my-litellm-gateway.example.com",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}

---

ANTHROPIC_AUTH_TOKEN=$(my-credential-helper) claude
RAW_BUFFERClick to expand / collapse

Summary

Gateway model discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1) fails silently when authentication is provided via apiKeyHelper in managed settings. The /v1/models request appears to run before the credential helper is invoked, resulting in an unauthenticated request that fails.

Reproduction

  1. Configure managed settings with apiKeyHelper and gateway discovery:
{
  "apiKeyHelper": "/usr/local/bin/my-credential-helper",
  "env": {
    "ANTHROPIC_BASE_URL": "https://my-litellm-gateway.example.com",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}
  1. Start Claude Code — /model picker does NOT show gateway models
  2. No ~/.claude/cache/gateway-models.json file is created (discovery fails silently)

Workaround

Setting ANTHROPIC_AUTH_TOKEN statically works:

ANTHROPIC_AUTH_TOKEN=$(my-credential-helper) claude

With this, gateway models appear in the /model picker as expected.

Expected behavior

Gateway model discovery should invoke the apiKeyHelper to obtain a token before making the /v1/models request, the same way inference requests do.

Environment

  • Claude Code version: 2.1.140
  • OS: macOS (arm64)
  • Gateway: LiteLLM proxy requiring bearer token auth on /v1/models

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…

FAQ

Expected behavior

Gateway model discovery should invoke the apiKeyHelper to obtain a token before making the /v1/models request, the same way inference requests do.

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 Gateway model discovery does not use apiKeyHelper for authentication [1 comments, 2 participants]