Claude Code CLI — Configuration with OmniRoute
Point the Claude Code CLI (claude) at OmniRoute — local or a remote VPS —
with per-model profiles, mirroring the Codex setup.
Quick start
# Launch Claude Code against a local OmniRoute (auto-detects the active context)
omniroute launch
# Against a remote OmniRoute (after `omniroute connect <host>`, this is automatic)
omniroute launch --remote http://192.168.0.15:20128 --api-key oma_live_xxx
# Generate per-model profiles, then launch one
omniroute setup-claude # writes ~/.claude/profiles/<name>/settings.json
omniroute launch --profile glm52 # Claude Code using glm/glm-5.2 via OmniRouteHow Claude Code connects to a gateway
Claude Code talks the Anthropic Messages API and is pointed at a custom
endpoint with environment variables (it has no --base-url flag):
| Variable | Purpose |
|---|---|
ANTHROPIC_BASE_URL | Gateway root URL (Claude Code appends /v1/messages). No /v1 suffix. |
ANTHROPIC_AUTH_TOKEN | Sent as Authorization: Bearer … — use your OmniRoute access token / API key |
ANTHROPIC_API_KEY | Alternative: sent as x-api-key. If both set, ANTHROPIC_AUTH_TOKEN wins |
ANTHROPIC_MODEL | Force a specific model (overrides the /model picker default) |
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY | 1 → the native /model picker lists claude*/anthropic* models from /v1/models |
CLAUDE_CODE_MAX_OUTPUT_TOKENS | Cap output tokens per response (e.g. 65536) |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | Token threshold for auto-compaction |
Env vars are read once at startup — restart Claude Code after changing them.
omniroute launch sets all of these for you: it resolves the base URL + token
from the active context (so omniroute connect <vps> then omniroute launch
just works), health-checks the server, and execs claude.
Profiles (CLAUDE_CONFIG_DIR)
Claude Code has no native profile files (unlike Codex's ~/.codex/<name>.config.toml).
The idiomatic mechanism is CLAUDE_CONFIG_DIR — a separate config directory per
profile, each with its own settings.json, credentials, history and cache.
omniroute setup-claude fetches the live /v1/models catalog and writes one
profile per model at ~/.claude/profiles/<name>/settings.json, reusing the
same names as setup-codex (glm52, kimi-k27, deepseek-pro, …):
// ~/.claude/profiles/glm52/settings.json
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "glm/glm-5.2",
"effortLevel": "xhigh",
"env": {
"ANTHROPIC_BASE_URL": "http://192.168.0.15:20128",
"ANTHROPIC_MODEL": "glm/glm-5.2",
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "190000",
},
}The auth token is never written to the profile. Launch with
omniroute launch --profile <name>(it injectsANTHROPIC_AUTH_TOKENfrom the active context), or exportANTHROPIC_AUTH_TOKENyourself and runCLAUDE_CONFIG_DIR=~/.claude/profiles/<name> claude.
Auto-sync after model discovery (opt-in). OmniRoute can regenerate these same
~/.claude/profiles/<name>/settings.json files automatically whenever a provider model
sync changes the live catalog — so new/renamed models get profiles without re-running the
command. It is off by default: toggle it from the CLI Code dashboard ("CLI profile
auto-sync" → Claude Code), or set OMNIROUTE_AUTO_SYNC_CLAUDE_PROFILES=true (it also honors
CLI_ALLOW_CONFIG_WRITES, on by default). When enabled it only writes profile files; it never
changes your active/default Claude config, auth, or the ~/.claude/settings.json.
Generating + using profiles
# Local OmniRoute
omniroute setup-claude
# Remote VPS (bakes the VPS URL into every profile)
omniroute setup-claude --remote http://192.168.0.15:20128 --api-key oma_live_xxx
# Only some providers
omniroute setup-claude --only glm,kimi
# Preview without writing
omniroute setup-claude --dry-run
# Launch a profile
omniroute launch --profile kimi-k27Model tiers (optional)
Claude Code routes to capability tiers. Map each to an OmniRoute model via env / settings if you want different providers per tier:
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm/glm-5.2"
export ANTHROPIC_DEFAULT_SONNET_MODEL="kmc/kimi-k2.6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm/glm-4.7-flash"Otherwise a single ANTHROPIC_MODEL (what profiles set) is used for everything.
Remote mode
Once you've run omniroute connect <host> (see
Remote Mode), omniroute launch and omniroute setup-claude
automatically target that remote server and use its scoped access token — no
extra flags needed. Override per-invocation with --remote / --api-key.
Troubleshooting
Claude Code ignores the gateway — confirm ANTHROPIC_BASE_URL has no
/v1 and restart claude (env is read once at startup). omniroute launch
handles this for you.
/model picker is empty / missing gateway models — needs Claude Code
v2.1.129+ and CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1. Only claude* /
anthropic* model IDs appear in the picker; force any other model with
ANTHROPIC_MODEL=<id> (this is what profiles do).
Auth errors — the profile holds no token. Use omniroute launch --profile
(injects it) or export ANTHROPIC_AUTH_TOKEN.
Profiles don't isolate — each profile is a distinct CLAUDE_CONFIG_DIR;
verify echo $CLAUDE_CONFIG_DIR inside the session points at
~/.claude/profiles/<name>.