Skip to content

Claude Code

Claude Code talks to Inferray's Anthropic-compatible endpoint, so it needs no adapter — two variables and it routes through your Inferray balance instead of your Claude subscription.

Set the variables

export ANTHROPIC_BASE_URL="https://api.inferray.com"
export ANTHROPIC_AUTH_TOKEN="inferray_..."

The base URL has no /v1 on it: Claude Code appends /v1/messages itself.

ANTHROPIC_AUTH_TOKEN sends your key as Authorization: Bearer, which is what Inferray reads. ANTHROPIC_API_KEY also works — it sends the key as x-api-key, which Inferray accepts too — but it needs a one-time approval in an interactive session, so the auth token is the smoother option.

Make it persistent

Shell exports only apply to that terminal and anything launched from it. To have every session route through Inferray, put the same values in the env block of ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.inferray.com",
    "ANTHROPIC_AUTH_TOKEN": "inferray_..."
  }
}

A settings-file value wins over a shell export of the same variable.

For the VS Code extension, set them in VS Code's own user settings instead — the extension checks credentials before it launches, so this is the one place it reliably reads:

{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://api.inferray.com" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "inferray_..." }
  ]
}

Choose the model

Set ANTHROPIC_MODEL to any model id from the catalogue — including the non-Claude ones, since every model answers on the Messages endpoint.

export ANTHROPIC_MODEL="claude-opus-4-8"

Claude Code's /model picker lists its own built-in names. It can also discover a gateway's models, which Inferray can answer since it serves GET /v1/models — but those entries are OpenAI-shaped, so ANTHROPIC_MODEL remains the reliable way to pin a model.

Check it worked

Send one request straight at the endpoint before opening the agent, so a failure points at the configuration rather than the tool:

curl -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model": "claude-opus-4-8", "max_tokens": 1, "messages": [{"role": "user", "content": "."}]}'

A response beginning {"id":"msg_ means the URL and key both work. A 401 means the key was rejected. A 402 means your balance is too low — top up and try again.

Then start claude from the same shell and run /status: an Anthropic base URL line showing api.inferray.com confirms requests are routing here.

While the variables are set

Your claude.ai login stays saved but unused, and its usage limits don't apply — the session bills to your Inferray balance instead. Unset the variables and Claude Code goes back to the subscription.