Claude Code
Use eWest models in the Claude Code terminal agent.
Claude Code talks to eWest over the Anthropic Messages API (/v1/messages). Point it at https://api.ewest.ai, give it your eWest key, and pick ewest/claude-* models.
Setup
Set ANTHROPIC_BASE_URL to https://api.ewest.ai, without /v1, and your key in ANTHROPIC_AUTH_TOKEN, which Claude Code sends as Authorization: Bearer. ANTHROPIC_API_KEY works too (sent as x-api-key); in an interactive session Claude Code asks once before using it. Set one of the two, not both.
Shell exports last for one terminal. To keep the settings, put them in the env block of ~/.claude/settings.json. Never put your key in a project's .claude/settings.json: that file is committed.
# ANTHROPIC_AUTH_TOKEN is sent as "Authorization: Bearer". No /v1 on the base URL.
export ANTHROPIC_BASE_URL=https://api.ewest.ai
export ANTHROPIC_AUTH_TOKEN="$EWEST_KEY"
export ANTHROPIC_MODEL=ewest/claude-sonnet
claudeChoose a model
ANTHROPIC_MODEL is the main model. The ANTHROPIC_DEFAULT_OPUS_MODEL, _SONNET_ and _HAIKU_ variables decide what the opus, sonnet and haiku aliases mean; the haiku one also runs background tasks such as session titles, so a cheap model there saves money.
- Every name needs the
ewest/prefix:ewest/claude-sonnetworks,claude-sonnetreturns404. ewest/claude-opusfor the hardest tasks,ewest/claude-sonnetfor everyday coding,ewest/claude-haikufor fast, cheap work. The full list is in Models.- With
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, the/modelpicker also lists theewest/claude-*models your key may use (Claude Code reads them fromGET /v1/models).
# The main model, and what the opus / sonnet / haiku aliases and background tasks use.
export ANTHROPIC_MODEL=ewest/claude-sonnet
export ANTHROPIC_DEFAULT_OPUS_MODEL=ewest/claude-opus
export ANTHROPIC_DEFAULT_SONNET_MODEL=ewest/claude-sonnet
export ANTHROPIC_DEFAULT_HAIKU_MODEL=ewest/claude-haiku
# One session on another model:
claude --model ewest/claude-opusVerify it works
claude -p sends one prompt and prints the answer. In an interactive session, /status shows the Anthropic base URL and which key variable is active. If Claude Code fails, try the cURL request: it uses the same key and model without Claude Code.
Every response has an x-request-id header; paste it into the console under Requests to see the request (trace IDs).
export ANTHROPIC_BASE_URL=https://api.ewest.ai
export ANTHROPIC_AUTH_TOKEN="$EWEST_KEY"
claude -p "Reply with the single word OK" --model ewest/claude-sonnetStreaming and tools
Nothing to set up: Claude Code always streams, and runs its tools (reading and editing files, shell commands) through tool calling on /v1/messages. In scripts, --output-format stream-json --verbose prints every event, including tool calls, as a JSON line.
export ANTHROPIC_BASE_URL=https://api.ewest.ai
export ANTHROPIC_AUTH_TOKEN="$EWEST_KEY"
# Streams every event (text, tool calls, tool results) as JSON lines.
claude -p "How many files are in this folder? Use ls." \
--model ewest/claude-sonnet \
--allowedTools "Bash(ls:*)" \
--output-format stream-json --verboseTroubleshooting
401: the key is missing, mistyped or revoked. Copy it again from API keys. Run/statusto see which variable Claude Code uses, and set only one ofANTHROPIC_AUTH_TOKENandANTHROPIC_API_KEY.404withmodel_not_found: the model name needs theewest/prefix (ewest/claude-haiku, notclaude-haiku) and must be in Models.400namingcontext_management,output_configorExtra inputs are not permitted: setCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1.400withoutput_config.effort is not supported by this model: Claude Code sends an effort setting thatewest/claude-haikudoes not take on/v1/messages. Useewest/claude-sonnetorewest/claude-opusas the main model.ewest/claude-haikuis the exception on/v1/messages, even though itsreasoning_effortslist effort values for other endpoints.- Claude Code asks you to log in although the key is set: put
ANTHROPIC_AUTH_TOKENin your shell or in~/.claude/settings.json, not only in a project settings file. - Harmless, nothing to fix: the first request of a session can get a
400saying rolesystemis not supported, which Claude Code retries by itself; a warning that the model is not recognized; and a cost estimate inside Claude Code that differs from your eWest usage. Your real cost is in the console under Usage.
# 400 errors naming context_management, output_config or "Extra inputs are not permitted":
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
# 401 errors: your key is in a header eWest does not read. Use one of these, not both:
export ANTHROPIC_AUTH_TOKEN="$EWEST_KEY" # sent in the Authorization header
# export ANTHROPIC_API_KEY="$EWEST_KEY" # sent as x-api-key (approve it once in /config)
# See what Claude Code uses: run /status inside Claude Code, or list the models your key may call:
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/modelsStill stuck? Follow Troubleshoot a request.