One command
~/.claude/settings.json, backs up what was there,
and is safe to re-run. See CLI for everything it can do.
By hand
Set four variables — in~/.claude/settings.json under env, or exported in your shell:
ANTHROPIC_BASE_URL— the gateway origin only. Do not append/v1; Claude Code adds/v1/messagesitself.ANTHROPIC_AUTH_TOKEN— yourlx1_key.ANTHROPIC_MODEL— the main model.lx1-sonnet-4.6for the premium ceiling (vision, top reasoning), orlx1-gpt-oss-120bfor a fast everyday driver. Any catalog id works.ANTHROPIC_SMALL_FAST_MODEL— the model for quick auxiliary calls;lx1-glm-4.7-flashkeeps them near-free.
Verify
Startclaude and run a trivial prompt. To confirm the wiring end-to-end without Claude
Code in the loop:
Troubleshooting
- Still using your Anthropic account? If you were signed in before, run
/logoutonce so Claude Code picks upANTHROPIC_AUTH_TOKENinstead of the stored session. - 404s on every call? The base URL probably includes
/v1— use the bare origin. - 401 unauthorized? The key must be in
ANTHROPIC_AUTH_TOKEN(notANTHROPIC_API_KEY) for a gateway base URL. - Context meter looks off? Claude Code budgets with count_tokens, which returns an estimate — billing always uses exact usage from real responses.
Model choice is per-variable, so you can run the premium model as the main driver and
keep the fast tier on auxiliary calls — every plan includes both.