ANTHROPIC_BASE_URL, authenticate with your Pioneer API key, and switch models with /model or pioneer/auto.
Quick setup
1
Install Claude Code
Download and set up Claude Code.
2
Persist Pioneer env vars
Create
~/.pioneer/env with these contents:Shell commands to create and source this file
Shell commands to create and source this file
3
Clear stale Claude.ai auth
Sign out of Claude.ai so Claude Code uses your Pioneer key:If Claude Code previously asked whether to trust this API key and you chose No, move the key tail from
customApiKeyResponses.rejected to approved in ~/.claude.json, or rerun setup from the Pioneer dashboard integration guide (it repairs this automatically).4
Install the routed-savings hook
When you use
pioneer/auto, Pioneer stamps pioneer_savings on each response — the per-1M-token price difference between the model the router picked and a frontier reference model. Claude Code does not surface that by default, so install a Stop hook (Claude Code’s end-of-turn hook) that multiplies those rate differences by your actual token usage, sums them across the session, and ends each turn with a line like:Show hook installer script
Show hook installer script
5
Seed the /model picker cache
Claude Code reads gateway models from
~/.claude/cache/gateway-models.json. Seed it once after setup (and again if the catalog changes):Show seed script (Python)
Show seed script (Python)
6
Launch Claude Code
/model inside Claude Code to pick a specific Pioneer model, or keep pioneer/auto to use the Code Router.Use the Code Router (pioneer/auto)
pioneer/auto sends each turn through Pioneer’s Code Router. The router picks the cheapest model that meets your quality bar for that specific prompt.
- Set
ANTHROPIC_CUSTOM_MODEL_OPTION=pioneer/autoso Claude Code treats it as a first-class custom model. - Launch with
claude --model pioneer/auto, or select it from/model. - After each turn, the Stop hook shows how much
pioneer/autorouting has saved you this session.
What does Stop says: mean?
Claude Code has a hooks system. Stop is one hook event — it runs after the assistant finishes a turn (not when you exit the session).
The Pioneer setup registers a Stop hook in ~/.claude/settings.json. That script reads the pioneer_savings rate differences and the per-turn token usage from the session transcript, sums the savings across the session, and emits a short message. Claude Code labels hook output with the hook name, so the UI shows:
pioneer_routed_model and pioneer_savings on Anthropic-compatible responses (streaming message_start frames and non-streaming bodies) if you want to build your own tooling around routing metadata.
Full model list in /model
Claude Code only shows third-party gateway models whose IDs start with claude or anthropic. Pioneer publishes discovery aliases such as anthropic/pioneer/gpt-5.4 on GET /v1/models so non-Claude decoder models appear in the picker while still resolving to the canonical Pioneer model ID at inference time.
Requirements:
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1ANTHROPIC_BASE_URLpointing at Pioneer- A populated
~/.claude/cache/gateway-models.json(see setup step above)
Troubleshooting
Claude Code says Not logged in · Please run /login
Claude Code says Not logged in · Please run /login
This usually means Claude Code did not pick up a usable Pioneer API key for the current shell. It is not asking you to sign in to Claude.ai.
- Run
. ~/.pioneer/env, then restart Claude Code. - If Claude Code asks whether to use the environment API key, accept it.
- Run
/statusand confirm:- API key is
ANTHROPIC_API_KEY - Anthropic base URL is your Pioneer endpoint
- Auth token is
none
- API key is
- If
/statuspoints at Pioneer but the error persists, check~/.claude.json. UndercustomApiKeyResponses, make sure the suffix for your current Pioneer key is inapproved, notrejected. - If you are using a non-production Pioneer endpoint, make sure the API key comes from the same environment.
Claude.ai login conflicts with your Pioneer key
Claude.ai login conflicts with your Pioneer key
If you see
Both claude.ai and ANTHROPIC_API_KEY set · auth may not work as expected, Claude Code is still using Claude.ai OAuth instead of your Pioneer key.- Run
claude auth logout(or/logoutinside Claude Code). - Relaunch with
claude --model pioneer/auto. When prompted about the environment API key, accept it. - Verify with
/status:- Auth token should be
none - API key should be
ANTHROPIC_API_KEY - Anthropic base URL should be your Pioneer endpoint
- Auth token should be
/model only shows built-ins and pioneer/auto
/model only shows built-ins and pioneer/auto
- Confirm
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1is set in~/.pioneer/envand sourced. - Check that
~/.claude/cache/gateway-models.jsonexists and itsbaseUrlmatchesANTHROPIC_BASE_URL. - Remove
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1from~/.claude/settings.jsonif present. - Rerun the cache seed step from setup.
No savings line after each turn
No savings line after each turn
Install the Stop hook from the setup section. It only runs when
ANTHROPIC_BASE_URL points at Pioneer, and the line appears only once pioneer/auto routing has actually saved money versus the frontier reference model this session. A brand-new session, or one where the router picked the frontier model itself, will show nothing until there are positive savings to report.