integrations/sdk/Anthropic SDK

Anthropic SDK + AIgateway

Official Anthropic SDK, drop-in — swap the base URL.

AIgateway now speaks the Anthropic Messages API natively, so the official `anthropic` SDK works unchanged. Point its base URL at AIgateway, use your sk-aig- key, and call client.messages.create as you always have. Pass a bare Claude name to run on Claude, or any AIgateway slug to run the Anthropic SDK on any model in the catalog.

Anthropic SDK homepage →
Setup

Three steps or fewer.

STEP 01

Python — official anthropic SDK

Point base_url at AIgateway's /anthropic path and use your sk-aig- key. The SDK sends it as x-api-key automatically; the gateway accepts it.

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"}],
)
print(msg.content[0].text)
STEP 02

TypeScript — official anthropic SDK

Same swap on the JS side, via the @anthropic-ai/sdk package.

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

const client = new Anthropic({
  baseURL: "https://api.aigateway.sh/anthropic",
  apiKey: process.env.AIGATEWAY_API_KEY,
});

const msg = await client.messages.create({
  model: "claude-opus-4.7",
  max_tokens: 1024,
  messages: [{ role: "user", content: "hi" }],
});
Notes
  • The SDK sends your sk-aig- key as the x-api-key header automatically — no extra config.
  • Bare Claude names (claude-opus-4.7, claude-sonnet-4.6, claude-haiku-4.5) map to the catalog slugs, OR pass any AIgateway slug (e.g. model="openai/gpt-5.4") to run the Anthropic SDK on any model.
  • The OpenAI-compatible path (/v1/chat/completions with anthropic/* slugs) also still works.
More integrations

Same key. Every other tool.