Skip to content

Migrating from Anthropic

If you're already using the Anthropic API (the Claude API), switching to TrustedRails takes two changes: the base URL and the API key. TrustedRails serves the Anthropic Messages API natively, so your existing SDK code keeps working; only the models change.

from anthropic import Anthropic
client = Anthropic(
api_key="tr-prx-your-api-key", # ← your TrustedRails key
base_url="https://proxy.trustedrails.com", # ← TrustedRails endpoint, no /v1
)
# Everything else stays exactly the same
response = client.messages.create(
model="MiniMaxAI/MiniMax-M2.7",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "tr-prx-your-api-key", // ← your TrustedRails key
baseURL: "https://proxy.trustedrails.com", // ← TrustedRails endpoint, no /v1
});
// Everything else stays exactly the same
const response = await client.messages.create({
model: "MiniMaxAI/MiniMax-M2.7",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello!" }],
});

Note the base URL is the bare host, without a /v1 suffix; Anthropic clients append the API paths themselves.

The official Anthropic SDKs read both values from the environment, so you can migrate without touching code:

.env
ANTHROPIC_API_KEY=tr-prx-your-api-key
ANTHROPIC_BASE_URL=https://proxy.trustedrails.com

Replace the Claude model name with a TrustedRails-supported model; claude-* model ids are not aliased, so this change is required. See Supported Models for the full list.

Common mappings:

| Instead of | Try | |---|---| | claude-sonnet-* | MiniMaxAI/MiniMax-M2.7 | | claude-opus-* | zai-org/GLM-5.3-Flash (bigger context window) |

Streaming with the standard Anthropic SSE events, tool use with full round-trips, system prompts, stop_sequences, and token counting all work. Models with extended reasoning return their reasoning as thinking content blocks, just like Anthropic clients expect — and the standard thinking parameter controls it: {"type": "disabled"} turns thinking off on models with a thinking switch. Note the models think by default, so you get thinking blocks without asking. See Anthropic API Compatibility for the full parameter list and the known divergences.

The same two changes apply (base URL and key), except the OpenAI base URL includes the version prefix: https://proxy.trustedrails.com/v1. See Migrating from OpenAI.