Skip to content

Show every model in the /model picker via gateway discovery - #9

Merged
BeLazy167 merged 1 commit into
mainfrom
feat/model-picker-discovery
Aug 21, 2026
Merged

Show every model in the /model picker via gateway discovery#9
BeLazy167 merged 1 commit into
mainfrom
feat/model-picker-discovery

Conversation

@BeLazy167

Copy link
Copy Markdown
Member

Closes the last gap: /model inside a session now lists all 12 models.

How (from primary-source research, checked into docs/research/)

Claude Code has a documented gateway-discovery mechanism:
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 makes it fetch
{ANTHROPIC_BASE_URL}/v1/models at startup and add picker rows labeled
"From gateway" — but a hard filter keeps only ids containing
claude/anthropic. Three pieces make GPT models pass it cleanly:

  1. Dual aliases: every GPT model is also served as
    anthropic-compat/<id>. The alias is the inference mapping, so picking the
    row routes to the real model — no strip logic anywhere.
  2. claude-code.disable-cloaking-model-list: true: without it CLIProxyAPI
    applies its own filter workaround and serves reversed pseudo-claude ids
    (claude-fable-5-dd-los-6.5-tpg — that's gpt-5.6-sol backwards). Real
    discovery, gibberish picker.
  3. Feature gate: that option is recent, so the installer feature-detects
    it on the candidate binary (strings | grep) and upgrades via
    brew/release download when absent — never version-string parsing.

The bug the gate grew

strings | grep -q under set -euo pipefail fails on SUCCESS: grep exits at
the first match, strings dies of SIGPIPE. Same class as the json extractors
in #4; same subshell guard, plus a regression test in tests/extractors.sh.

Verified live (fresh delete + reinstall)

picker cache (~/.claude/cache/gateway-models.json) 12 rows: 4 claude + 8 anthropic-compat/gpt-*
claude via proxy
--model gpt-5.6-sol (plain alias)
--model anthropic-compat/gpt-5.4 (picker row id)
suites routing 6/6, statusline 12/12, extractors 6/6, shellcheck clean

Research report with binary offsets and doc citations:
docs/research/2026-08-20-model-picker.md.

Background research (docs/research/2026-08-20-model-picker.md) found Claude
Code's supported mechanism: CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
fetches {base}/v1/models at startup and adds rows labeled "From gateway" —
keeping only ids containing claude|anthropic. So:

- Each GPT model gets a second alias, anthropic-compat/<id>, which passes the
  filter with a readable name; the alias IS the inference mapping, so picking
  the row just works.
- The launcher exports the discovery flag on the proxy route.
- claude-code.disable-cloaking-model-list: true in the proxy config —
  without it CLIProxyAPI serves the picker REVERSED pseudo-claude ids
  (claude-fable-5-dd-los-6.5-tpg), which is its own filter workaround and
  reads as gibberish.
- That option needs a recent CLIProxyAPI, so the installer feature-detects it
  on the binary (strings | grep) and upgrades/downloads when absent.

The feature gate initially failed on success: grep -q exits at first match,
strings dies of SIGPIPE, pipefail turns that into failure — the same class as
the json extractors. Guarded the same way, with a regression test.

Verified live on a fresh reinstall: 12 picker rows cached (4 claude +
8 anthropic-compat/gpt), inference on plain and prefixed ids, claude direct.
@BeLazy167
BeLazy167 merged commit ee9caf6 into main Aug 21, 2026
6 checks passed
@BeLazy167
BeLazy167 deleted the feat/model-picker-discovery branch August 21, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant