Anthropic SDK (Python)
Set the Anthropic Python SDK’s base URL to the gateway plus your app slug. The SDK appends /v1/messages itself and the gateway speaks Anthropic’s protocol natively, so nothing is translated.
import os
import anthropic
client = anthropic.Anthropic(
base_url="http://127.0.0.1:8787/w/my-service",
api_key=os.environ["ANTHROPIC_API_KEY"],
)
msg = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
# Connected to Caveman Cloud? Add gateway auth + BYOK headers:
# default_headers={"x-cave-api-key": CAVE_API_KEY, "x-cave-upstream-key": ANTHROPIC_API_KEY}The SDK appends /v1/messages itself, so the base URL is just the gateway + /w/my-service.
Local vs. connected
The base URL above is the local proxy default (http://127.0.0.1:8787). Connected or managed use swaps in the cloud gateway URL and adds x-cave-api-key (gateway auth) plus x-cave-upstream-key (your per-request provider key) — the trailing comment in the snippet shows exactly where they go.