Skip to content

Connect Claude Code to TrustedRails

Claude Code is Anthropic's agentic coding tool. It talks the Anthropic Messages API, and TrustedRails serves that same protocol natively, so pointing your agent at TrustedRails is three environment variables, with no router or local proxy in between. The full agentic loop works over this endpoint: multi-turn sessions, tool use, streaming, and thinking blocks.

Set the Anthropic environment variables and start Claude Code from the same shell:

Terminal window
export ANTHROPIC_BASE_URL="https://proxy.trustedrails.com"
export ANTHROPIC_AUTH_TOKEN="tr-prx-your-api-key"
export ANTHROPIC_MODEL="MiniMaxAI/MiniMax-M2.7"
export ANTHROPIC_SMALL_FAST_MODEL="MiniMaxAI/MiniMax-M2.7"
claude
  • ANTHROPIC_BASE_URL is the bare proxy host, with no /v1 suffix. Claude Code appends the API paths itself.
  • ANTHROPIC_MODEL must be a model id TrustedRails serves, exactly as listed in Supported Models. MiniMaxAI/MiniMax-M2.7 is a strong default for agentic coding; deepseek-ai/DeepSeek-V4-Flash-0731 is an alternative with a bigger context window.
  • ANTHROPIC_SMALL_FAST_MODEL covers the background tasks Claude Code normally sends to a small Claude model. Point it at the same id so those calls don't go looking for a model TrustedRails doesn't serve.

To make the switch permanent instead of per-shell, put the same variables in the env block of ~/.claude/settings.json:

{
"env": {
"ANTHROPIC_BASE_URL": "https://proxy.trustedrails.com",
"ANTHROPIC_AUTH_TOKEN": "tr-prx-your-api-key",
"ANTHROPIC_MODEL": "MiniMaxAI/MiniMax-M2.7",
"ANTHROPIC_SMALL_FAST_MODEL": "MiniMaxAI/MiniMax-M2.7"
}
}

Work with Claude Code exactly as before: chat, let it read and edit files, run commands, and iterate. Only the endpoint and the model changed; requests are billed per token from your TrustedRails balance.

Start claude and ask it to do something small but real: read a file and summarize it, or make a one-line edit. A completed answer confirms the connection; a completed edit confirms the full tool-use loop.

  • "Unknown model" / context-window warning at startup: cosmetic. Claude Code doesn't recognize open-source model ids and assumes a default context size; requests work normally.
  • 401 / invalid API key: wrong or paused key, or the variables aren't set in the shell where you started claude. Re-export them (or check ~/.claude/settings.json), or create a fresh key from Create a TrustedRails API Key.
  • Model not found: ANTHROPIC_MODEL must match a model TrustedRails serves exactly (see Supported Models).
  • Errors only on background/sub-agent tasks: set ANTHROPIC_SMALL_FAST_MODEL (some Claude Code versions read ANTHROPIC_DEFAULT_HAIKU_MODEL instead) to the same model id.
  • Thinking blocks appear without extended thinking enabled: expected — the models TrustedRails serves think by default, unlike Anthropic's (see known divergences). The thinking parameter is honored if your client sends it.

Claude Code is a trademark of Anthropic. TrustedRails is an independent service and is not affiliated with or endorsed by Anthropic.