Agent Setup

Claude Code

Quick answer
Prism writes six environment keys into ~/.claude/settings.jsonthat redirect Claude Code's Anthropic Messages traffic to Prism. Each of Claude Code's four tiers — opus, sonnet, haiku and subagent — can be mapped to a different upstream model.

Last updated Reviewed against Prism v0.3.26

One-click setup

1

Open the Agents tab

In the Admin UI, select Agents. Claude Code appears in the detected list when ~/.claude/settings.json or ~/.claude/settings.local.json exists.
2

Click Setup

Prism backs up the existing file to ~/.claude/settings.json.prism-backup, then writes the managed env keys.
3

Choose a model per tier

Pick a Prism model for opus, sonnet, haiku and subagent. Each becomes its own environment variable, so the main thread, quick completions and background agents can run on different models.
4

Restart Claude Code

Claude Code reads ANTHROPIC_BASE_URL at startup, so a restart is required for the change to take effect.

What Prism writes

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:11434",
    "ANTHROPIC_AUTH_TOKEN": "prism",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.1:cloud",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-flash:cloud",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash:cloud",
    "CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-flash:cloud"
  }
}

Nothing else in the file is touched. On disable, only these six keys are removed and your own env entries are left alone.

The four tiers

Environment variableControls
ANTHROPIC_DEFAULT_OPUS_MODELThe main thread — the most capable work.
ANTHROPIC_DEFAULT_SONNET_MODELThe balanced default.
ANTHROPIC_DEFAULT_HAIKU_MODELFast background completions.
CLAUDE_CODE_SUBAGENT_MODELSub-agents that Claude Code spawns for parallel work.

Pointing haiku and subagent at a cheaper model is the single biggest cost lever in a Claude Code setup, because background tasks usually dominate request count. See Model Remapping.

Claude Code may rewrite the file — Prism re-syncs it
Claude Code watches and rewrites ~/.claude/settings.jsonon its own, which can drop Prism's keys. Prism re-writes them on every startup, so a lost key recovers as soon as Prism restarts. If Claude Code suddenly talks to Anthropic directly again, restart Prism or click re-sync in the Agents tab.

Manual setup

If you prefer to edit the file yourself, add the same six keys under env. The base URL is the proxy root with no path — Claude Code appends /v1/messages itself.

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:11434",
    "ANTHROPIC_AUTH_TOKEN": "prism"
  }
}
Do not use ANTHROPIC_API_KEY
Prism expects ANTHROPIC_AUTH_TOKEN. Leaving ANTHROPIC_API_KEY set makes Claude Code send an x-api-key header as well, which Prism also accepts but which can mask a misconfigured auth token.

Add MCP servers

Claude Code keeps user-scope MCP servers in ~/.claude.json under mcpServers. Prism can write a single gateway entry there so Claude Code gets every server you allowed, with its own OAuth brokering handled by Prism. See MCP Gateway.

Verify

CheckExpected
Claude Code starts without an auth errorPrism is answering on :11434.
A prompt returns a model name from your catalogPer-tier mapping is in effect.
The request appears in the Stats tabClient should show as Claude Code.