Guides · Claude Code
Claude Code on Layer X1.
Claude Code speaks the Anthropic Messages dialect natively — pointing it at Layer X1 is four environment variables, or one command.
One command
npx layerx1 setup --tool claude-code --key lx1_your_keyThe CLI writes the config below into ~/.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:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.layerx1.in",
"ANTHROPIC_AUTH_TOKEN": "lx1_your_key",
"ANTHROPIC_MODEL": "lx1-sonnet-4.6",
"ANTHROPIC_SMALL_FAST_MODEL": "lx1-glm-4.7-flash"
}
}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
Start claude and run a trivial prompt. To confirm the wiring end-to-end without Claude Code in the loop:
npx layerx1 test --key lx1_your_keyTroubleshooting
- 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.
Note
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.