Connect Claude Code to Anoman AI
Route Claude Code and any Anthropic SDK client through Anoman using the Anthropic-compatible proxy endpoint. All guardrails apply to every request — including streaming completions and tool calls.
Prerequisites
- An Anoman AI account with an active API key
- Claude Code CLI installed (
npm install -g @anthropic-ai/claude-code) - Or: Python 3.9+ with
anthropicSDK installed
Anthropic-compatible endpoint
Claude Code uses the Anthropic Messages API format, not the OpenAI format. Anoman exposes a separate Anthropic-compatible endpoint at /anthropic. Use this endpoint — not the /v1 OpenAI endpoint — for Claude Code and the Anthropic Python SDK.
Step 1: Configure Claude Code CLI
Set two environment variables before launching Claude Code. The CLI reads these automatically.
export ANTHROPIC_BASE_URL=https://api.anoman.io/anthropic
export ANTHROPIC_API_KEY=anm-sk-your-key-here
# Launch Claude Code — all requests now route through Anoman
claudeStep 2: Python SDK configuration
Pass base_url when constructing the Anthropic client. The SDK sends all requests to the Anoman proxy, which applies guardrails before forwarding to Anthropic.
import anthropic
client = anthropic.Anthropic(
api_key="anm-sk-your-key-here",
base_url="https://api.anoman.io/anthropic",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Summarize this document."}],
)
print(message.content[0].text)Streaming responses
Streaming works identically through the Anoman proxy. Guardrails run on the prompt before the stream opens.
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain this code."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)When a guardrail triggers
If a request is blocked by the guardrail pipeline, Anoman returns a 403 before any content reaches Anthropic. The SDK surfaces this as an anthropic.APIStatusError.
try:
message = client.messages.create(...)
except anthropic.APIStatusError as e:
if e.status_code == 403:
print("Blocked by guardrail:", e.body)
raiseCheck docs/openapi/ for the current error schema.
Guardrail transparency headers
Every response from the Anoman proxy includes guardrail result headers. Inspect these in your logs to verify the pipeline is active.
X-Anoman-Guardrail-Injection: pass score=0.04
X-Anoman-Guardrail-Pii: pass
X-Anoman-Guardrail-Content: pass
X-Anoman-Cache: noneNeed help with your integration?
Join the Founding 50 for early access and direct support from the Anoman team.
Join Founding 50