Anthropic SDK (TypeScript)
Set the Anthropic JavaScript 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. Claude Pro/Max OAuth bearer tokens pass through unchanged.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "http://127.0.0.1:8787/w/my-service",
apiKey: process.env.ANTHROPIC_API_KEY,
});
const msg = await client.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Why is the sky blue?" }],
});
// Claude Pro/Max OAuth bearer tokens pass through unchanged.
// Connected to Caveman Cloud? Add gateway auth + BYOK headers:
// defaultHeaders: { "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.