Melious
Integrations

Claude Code

Anthropic's coding agent, routed through Melious — two env vars, no fork, full session support

Claude Code
by Anthropicclaude.ai/code

Claude Code is Anthropic's official terminal coding agent — a single claude command that reads files, makes edits, runs tools, and holds a session's worth of context across turns. The distinguishing behavior is how hard it pushes on exploration: slash commands, long tool chains, multi-file edits, thorough summaries. That thoroughness costs tokens. Because it reads ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, pointing it at Melious is two environment variables — our Messages endpoint implements the Anthropic SDK and maps claude-* model names to the open-weight models we actually run.

Claude Code burns a lot more tokens than most agents for the same task. Every session gets logged with its own environment_impact and billing_cost server-side — you'll see the energy and spend in your usage dashboard. The Anthropic SDK strips unknown response fields, so Claude Code itself won't surface them in the terminal. For cost-sensitive agent work, OpenCode is usually noticeably cheaper on the same model.

Setup

Skip the steps with the Melious CLI

The CLI installs Claude Code, sets the env vars for the launched process, and starts a session. One command, nothing leaks into your shell profile.

melious tools install claude-code
melious launch claude-code

It scopes ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to the launched process, so any Anthropic auth you have outside this session stays untouched.

Install Claude Code

Use Anthropic's official installer.

macOS, Linux, WSL:

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Or a package manager:

brew install --cask claude-code            # macOS, Linux
winget install Anthropic.ClaudeCode        # Windows
npm install -g @anthropic-ai/claude-code   # any platform, requires Node 18+

Point Claude Code at Melious

Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN from the environment. The base URL is https://api.melious.aiwithout /v1. The Anthropic SDK appends its own version prefix, and double-prefixing breaks routing.

# Required.
export ANTHROPIC_BASE_URL=https://api.melious.ai  
export ANTHROPIC_AUTH_TOKEN=sk-mel-<YOUR_API_KEY>
export ANTHROPIC_API_KEY=""

# Recommended. Pins every slot Claude Code may reach for at
# runtime — including hard-coded names like `claude-haiku-4-5`
# Anthropic uses for background tasks — to a known Melious model.
# Also raises the request timeout for long agent runs and stops
# Claude Code from phoning home to Anthropic for telemetry.
export ANTHROPIC_MODEL=<MODEL_ID>
export ANTHROPIC_SMALL_FAST_MODEL=<LIGHTWEIGHT_MODEL_ID>
export ANTHROPIC_DEFAULT_OPUS_MODEL=<MODEL_ID>
export ANTHROPIC_DEFAULT_SONNET_MODEL=<MODEL_ID>
export ANTHROPIC_DEFAULT_HAIKU_MODEL=<LIGHTWEIGHT_MODEL_ID>
export API_TIMEOUT_MS=3000000
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1

ANTHROPIC_API_KEY must be explicitly empty. If it's set to a real Anthropic key — from a previous direct-Anthropic setup, a CI secret, or a sourced dotfile — the SDK quietly prefers it over ANTHROPIC_AUTH_TOKEN and your traffic lands on api.anthropic.com instead of Melious. Blank it once, in the same place you set the other two.

If you've previously signed in with claude login, run /logout first to drop cached Anthropic credentials.

The five ANTHROPIC_*_MODEL lines lock every slot to an explicit Melious model. Without them, Claude Code can hit names that aren't in our substring map (claude-haiku-4-5, future versions, etc.) and the call fails. Pick model IDs from melious.ai/hub/models.

For a repo-checkable config, drop the same values into .claude/settings.local.json (Claude Code reads this on startup):

.claude/settings.local.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.melious.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-mel-<YOUR_API_KEY>",
    "ANTHROPIC_API_KEY": "",
    "ANTHROPIC_MODEL": "<MODEL_ID>",
    "ANTHROPIC_SMALL_FAST_MODEL": "<LIGHTWEIGHT_MODEL_ID>",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<LIGHTWEIGHT_MODEL_ID>",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

Run a session

claude

Ask it something and watch the usual Claude Code surface come up — agent mode, file edits, slash commands, tool calls. What changed is where the inference runs.

Sanity-check the wiring with /status inside the session — the auth token and base URL lines should read:

Auth token: ANTHROPIC_AUTH_TOKEN
Anthropic base URL: https://api.melious.ai

If Anthropic base URL is empty or shows api.anthropic.com, the env vars didn't reach the process — check the same shell you launched claude from.

How model names are mapped

Claude Code hard-codes Anthropic model names (opus, sonnet, haiku). We substring-match them at the edge and route each tier to a Melious model so you don't need a patched client:

Claude Code sends (anything containing)Routes to
opusmain model (configurable)
sonnetsecondary model (configurable)
haikulightweight model (configurable)
anything elsethe string as-is

The response carries the original claude-sonnet-4 (or whichever name you sent) back in the model field — so Claude Code's internal checks don't trip. The actually-executed model appears in your usage reports, not in the wire response.

The default mapping is admin-configurable per-instance. Browse melious.ai/hub/models for the current model list and see Routing for the full set of config keys.

Picking a specific model

Most current Claude Code releases accept arbitrary --model strings, so this works:

claude --model <MODEL_ID>

If your version validates against Anthropic's allow-list, set the ANTHROPIC_DEFAULT_*_MODEL env vars instead — Claude Code passes whatever string you put there straight through to the API:

export ANTHROPIC_MODEL=<MODEL_ID>
export ANTHROPIC_SMALL_FAST_MODEL=<LIGHTWEIGHT_MODEL_ID>
export ANTHROPIC_DEFAULT_OPUS_MODEL=<MODEL_ID>
export ANTHROPIC_DEFAULT_SONNET_MODEL=<MODEL_ID>
export ANTHROPIC_DEFAULT_HAIKU_MODEL=<LIGHTWEIGHT_MODEL_ID>
export CLAUDE_CODE_SUBAGENT_MODEL=<MODEL_ID>

These are passed through verbatim by Claude Code, and Melious accepts arbitrary model strings server-side, so they're the most reliable way to lock in a specific model. Pin every slot — Claude Code uses *_HAIKU_* and SMALL_FAST_MODEL for background and agent-spawn calls, so leaving them unset can route quietly to whatever's mapped to haiku. Find current IDs at melious.ai/hub/models.

What's different

  • Responses carry extra fields server-side. environment_impact and billing_cost ride on every completion. The Anthropic SDK drops unknown fields before Claude Code sees them, but they're logged and surfaced in your usage dashboard.
  • Prompt caching (cache_control) is not exposed. Open-weight providers don't surface the same cache handles Anthropic does, and we haven't written a translation. Sessions re-send context each turn; plan costs accordingly. If you need this, tell us.
  • Extended thinking blocks pass through as regular text for non-reasoning models. Reasoning-class models produce thinking as part of their output, but the exact Anthropic thinking block shape isn't preserved.

When it breaks

  • Hang on the first tokenANTHROPIC_BASE_URL probably has a trailing /v1. Strip it; the SDK adds it itself.
  • 401 immediately — the token string lost its sk-mel- prefix when you copied it, or the key was rotated. Paste the full 128-character key.
  • Traffic lands on api.anthropic.com / billing shows on Anthropic, not MeliousANTHROPIC_API_KEY is set somewhere (shell, dotfile, CI secret) and the SDK prefers it over ANTHROPIC_AUTH_TOKEN. Blank it: export ANTHROPIC_API_KEY="". If you previously ran claude login, also /logout to drop cached creds.
  • /status shows the wrong base URL — env vars didn't reach the process. Re-export in the same shell you launched claude from, or move the values into .claude/settings.local.json so they're read at startup regardless of shell state.
  • Tool loops feel different than with Claude — model-capability thing, not a protocol thing. Stronger models handle longer tool sequences; smaller ones give up earlier. Check _meta.capabilities.tool_use on GET /v1/models?include_meta=true and override the mapping with ANTHROPIC_DEFAULT_*_MODEL for long agent sessions.
  • Costs higher than expected — Claude Code's default prompt style is verbose. That's baked in. OpenCode runs the same agent workloads cheaper if that bothers you.

Errors and retry patterns: Errors.

On this page