Claude Code Gateway Models Missing? Fix apiKeyHelper Discovery

Claude Code Gateway Models Missing? Fix apiKeyHelper Discovery

Aident AI

A small coral current catches a cyan wave before both enter a calm blue field.

Claude Code Gateway Models Missing? Fix apiKeyHelper Discovery

If Claude Code can send prompts through your LLM gateway but /model has no "From gateway" entries, check the credential source before changing the gateway. Current reports show gateway discovery can skip /v1/models when authentication comes only from apiKeyHelper, even though the same helper works for inference. Confirm that exact split, then use a child-process ANTHROPIC_AUTH_TOKEN test or one explicit custom model while the upstream bug remains open.

This guide is for the narrow case where all of these are true:

  • ANTHROPIC_BASE_URL points to an Anthropic Messages-compatible gateway;

  • CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 is set;

  • apiKeyHelper supplies a valid short-lived credential;

  • normal Claude Code prompts succeed; and

  • /model does not show models returned by the gateway.

Do not use this diagnosis when inference also fails. That is an authentication or gateway-compatibility problem, not a discovery-only failure.

Confirm the Documented Gates

Anthropic documents gateway model discovery for Claude Code 2.1.129 or later. It runs only for a non-Anthropic ANTHROPIC_BASE_URL that exposes the Anthropic Messages format. The returned model IDs must begin with claude or anthropic.

Check only the non-secret inputs:

claude --version
printf 'base URL: %s\n' "$ANTHROPIC_BASE_URL"
printf 'discovery: %s\n' "$CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"
printf 'nonessential traffic disabled: %s\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"

Expected results:

  • Claude Code is 2.1.129 or newer;

  • the base URL is your gateway, not api.anthropic.com;

  • discovery prints 1; and

  • nonessential traffic is empty while you test discovery.

Do not print the helper output, an auth token, a settings file, or request headers into a shared terminal or issue report.

Reproduce the Silent Discovery Failure

Start one ordinary session with debug logging:

claude --debug

Inside Claude Code, run:

/status
/model

Exit, then inspect only the presence of the cache and discovery markers:

test -f ~/.claude/cache/gateway-models.json \
  && echo 'gateway cache present' \
  || echo 'gateway cache absent'

rg -n 'gatewayDiscovery|models\?limit|/v1/models' ~/.claude/debug/latest

Ask the gateway operator whether that launch produced GET /v1/models. Do not request or paste the authorization header.

The reported apiKeyHelper failure has a distinctive four-part signature:

Check

Discovery-only failure

Normal prompt

Succeeds through the gateway

/model

No "From gateway" rows

Cache

gateway-models.json is absent

Debug and gateway logs

No discovery marker or /v1/models request

If a request reached /v1/models and failed, inspect its HTTP status and response schema instead. If the request succeeded but models are missing, verify that their IDs start with claude or anthropic.

A/B Test the Credential Source Safely

The strongest public reproductions changed only the credential source. They used the same helper output as a child-scoped bearer token, then observed the discovery request, cache, and model rows.

On a trusted machine, replace the placeholder with the absolute path already configured as apiKeyHelper:

set +x
ANTHROPIC_AUTH_TOKEN="$(/absolute/path/to/get-token.sh)" claude --debug

This token exists only in the launched process environment. Do not use export, paste the token, enable shell tracing, or save it in a shell profile.

Run /model, exit, and repeat the cache and debug checks. Interpret the result narrowly:

  • If discovery now works, the credential source is the isolated variable. Keep the evidence and track the upstream reports.

  • If discovery still does not run, restore the ordinary launch path and check the documented gates again.

  • If inference fails in either run, stop. The experiment no longer isolates model discovery.

This is a diagnostic and short-lived workaround, not proof of Anthropic's internal root cause. The issue authors suspect discovery checks for a credential before asynchronous helper resolution finishes, but Anthropic has not confirmed that explanation.

Use One Explicit Model Without Changing Authentication

If you only need one gateway model, Anthropic documents an explicit picker entry. Ask the gateway operator for the exact non-secret model ID and set it for a fresh session:

export ANTHROPIC_CUSTOM_MODEL_OPTION="claude-your-approved-model"
export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="Approved gateway model"
claude

Claude Code skips its normal model-ID validation for this option, so use only an ID approved by the gateway owner. This adds one picker entry; it does not repair dynamic discovery or enumerate the gateway's catalog.

Remove the temporary variables when the upstream discovery path works with apiKeyHelper:

unset ANTHROPIC_CUSTOM_MODEL_OPTION
unset ANTHROPIC_CUSTOM_MODEL_OPTION_NAME

For the broader decision between secret-bearing local configuration and delegated access, see API keys vs OAuth for agent integrations. If the gateway problem is actually an MCP connection failure, use the separate Claude Code MCP connection diagnostic.

What Not to Do

  • Do not delete all of ~/.claude to force discovery.

  • Do not copy a short-lived token into project settings or a committed file.

  • Do not expose a helper's stdout, gateway headers, or access tokens in an issue.

  • Do not assume successful inference proves /v1/models was requested.

  • Do not hardcode a model ID that the gateway owner has not approved.

  • Do not describe the suspected startup-order explanation as an upstream-confirmed root cause.

Reusable Diagnostic Prompt

Give Claude Code this bounded request:

Diagnose missing gateway models without changing authentication or files. Report the Claude Code version, whether the non-secret gateway discovery gates are set, whether normal inference succeeds, whether /model has "From gateway" entries, whether the gateway cache exists, and whether the latest debug log contains discovery markers. Do not print credentials, execute apiKeyHelper, edit settings, delete caches, export tokens, or contact the gateway.

Success is measurable: you can say whether the problem is a discovery-only failure, whether /v1/models ran, and whether changing only the credential source changes the result.

To monitor the upstream reports without giving an agent a GitHub token, start with Aident Loadout:

Follow https://aident.ai/SETUP.md

Then ask:

Check Aident Loadout authentication and Vault status. Discover the current read-only GitHub issue Action, inspect its schema, and preflight lookups for anthropics/claude-code issues 84683, 83515, and 56675. If the lookups are valid and free, execute them and return only state, updated time, labels, title, and canonical URL. Do not comment, react, edit, close, or create anything.

Set up Aident Loadout and monitor gateway discovery.

Sources

Refresh this guide when issue 84683 changes state, Anthropic documents helper-backed discovery behavior, or a Claude Code release makes the child-scoped credential test unnecessary.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

The one tool

for every tool

your agent needs.

Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.