Anthropic SDK & Claude Code
The gateway serves the Anthropic Messages format natively at /v1/messages, so Anthropic SDKs and Claude Code connect by changing only their base URL and credential. Routed to an Anthropic deployment the body passes through losslessly; routed to any other backend (OpenAI-compatible, Gemini) it is translated — same client, any vendor.
Anthropic Python SDK
import anthropic
client = anthropic.Anthropic(
base_url="https://aam.example.com", # the SDK appends /v1/messages
api_key="sk-your-virtual-key", # sent as x-api-key
)
message = client.messages.create(
model="claude-sonnet", # a catalog alias
max_tokens=1024,
messages=[{"role": "user", "content": "hello"}],
)
The data-plane auth filter accepts the virtual key as x-api-key (the Anthropic way) as well as Authorization: Bearer, so stock Anthropic clients authenticate without modification.
Claude Code
Point Claude Code at the gateway with the standard environment variables:
export ANTHROPIC_BASE_URL="https://aam.example.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-virtual-key"
Claude Code keeps speaking its native wire format; the gateway relays it verbatim to an Anthropic-protocol deployment — tools, streaming, everything — while adding key governance, budgets, guardrails, and audit around it.
Serving Claude requests with non-Claude backends
Because /v1/messages translates when the routed deployment is not Anthropic-protocol, you can point the alias your Anthropic clients use at an OpenAI-compatible or Gemini deployment. The translation carries the system prompt, conversation (including images), core sampling parameters, and full tool use; streaming is emulated as a native Messages SSE sequence. Provider-specific extras outside that mapped set are dropped — keep truly Claude-specific workloads on a Claude deployment.
Governance notes
- Request guardrails screen every string leaf of the (otherwise opaque) native body; response screening applies when a response policy is in scope, including inline on passthrough streams with cross-chunk carry-over.
- Budgets and audit read the standard
usageblock, so metering is identical to the chat surface.
Related
- Gateway API — Messages — the wire contract and translate-path details.
- Gemini & Vertex AI — running Claude on Vertex through the same gateway.