Anthropic SDK on your own GPUs.
Your Anthropic API key stays in api_key; the warden key rides in its own header.
- Protocol
- Anthropic Messages
- Support
- Full support
- Verified
- Run against a live warden on 2026-10-04 with anthropic 1.11.0 (Python), @anthropic-ai/sdk 0.131.0, curl. Python, TypeScript and curl in both modes; router mode’s claude-haiku-4-5 was answered here.
The Claude models your rules name run here; every other model and /v1 path goes to Anthropic on your own login. Local only needs no Anthropic account: the warden key is the api_key and the model is a served name.
Requirements
- Routing must be on, with at least one enabled rule.
- The key must be allowed to relay to Anthropic (May relay).
Setup
In the console, Connect writes these files with your warden’s address, your key and the model you picked. Here they are with placeholders.
Router: keep your Anthropic key
base_url is this warden; your Anthropic API key stays in api_key and the warden key goes in default headers.
import anthropic
# api_key is your own Anthropic key (ANTHROPIC_API_KEY), used for pass-through.
client = anthropic.Anthropic(
base_url="https://your-warden",
default_headers={"X-LMWarden-Key": "vw_YOUR_KEY"},
)
message = client.messages.create(
model="claude-haiku-4-5", # a model your rules serve here; others go to Anthropic
max_tokens=256,
messages=[{"role": "user", "content": "Reply with the single word OK."}],
)
print(message.content[0].text)import Anthropic from "@anthropic-ai/sdk";
// apiKey is your own Anthropic key (ANTHROPIC_API_KEY), used for pass-through.
const client = new Anthropic({
baseURL: "https://your-warden",
defaultHeaders: { "X-LMWarden-Key": "vw_YOUR_KEY" },
});
const message = await client.messages.create({
model: "claude-haiku-4-5", // a model your rules serve here; others go to Anthropic
max_tokens: 256,
messages: [{ role: "user", content: "Reply with the single word OK." }],
});
console.log(message.content);curl https://your-warden/v1/messages \
-H "X-LMWarden-Key: vw_YOUR_KEY" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "claude-haiku-4-5", "max_tokens": 256, "messages": [{"role": "user", "content": "Reply with the single word OK."}]}'Local only
The warden key is the api_key and the model is a served name.
import anthropic
client = anthropic.Anthropic(base_url="https://your-warden", api_key="vw_YOUR_KEY")
message = client.messages.create(
model="your-served-model-name",
max_tokens=256,
messages=[{"role": "user", "content": "Reply with the single word OK."}],
)
print(message.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://your-warden", apiKey: "vw_YOUR_KEY" });
const message = await client.messages.create({
model: "your-served-model-name",
max_tokens: 256,
messages: [{ role: "user", content: "Reply with the single word OK." }],
});
console.log(message.content);curl https://your-warden/v1/messages \
-H "x-api-key: vw_YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "your-served-model-name", "max_tokens": 256, "messages": [{"role": "user", "content": "Reply with the single word OK."}]}'Official documentation: https://platform.claude.com/docs/en/api/sdks/python (read 2026-10-04).