integrations/sdk/Anthropic SDK
AN

Anthropic SDK + AIgateway

Official Anthropic client. Swap base URL, keep everything else.

AIgateway speaks the Anthropic Messages API too. Set the base URL to our Anthropic-shape endpoint and the official anthropic SDK works unchanged — Opus 4.7, Sonnet 4.6, Haiku 4.5, plus tool calling, vision, and streaming.

Anthropic SDK homepage →
Setup

Three steps or fewer.

STEP 01

Set the base URL

Same SDK, different host.

import anthropic

client = anthropic.Anthropic(
    base_url="https://api.aigateway.sh/anthropic",
    api_key="sk-aig-...",
)
msg = client.messages.create(
    model="claude-opus-4.7",
    max_tokens=1024,
    messages=[{"role":"user","content":"hi"}],
)
STEP 02

TypeScript

Same on the JS side.

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.aigateway.sh/anthropic",
  apiKey: process.env.AIGATEWAY_API_KEY,
});
Notes
  • If you'd rather use the OpenAI-shape endpoint everywhere, /v1/chat/completions also accepts anthropic/* model slugs.
More integrations

Same key. Every other tool.