Anthropic Agent SDK

Agent SDK runtime with TheRouter.ai as Anthropic endpoint

Anthropic Agent SDK inherits Claude Code runtime behavior. Environment overrides let those agent sessions use TheRouter.ai transparently.

Overview

This page mirrors the OpenRouter workflow and adapts it for TheRouter.ai. Use TheRouter.ai as your OpenAI-compatible endpoint and keep model IDs in `provider/model` format.

Installation

Install the required SDKs and keep your TheRouter.ai key in environment variables.

install.sh
npm install @anthropic-ai/claude-agent-sdk && pip install claude-agent-sdk

Configuration

Set TheRouter.ai base URL overrides and pass your API key. Add attribution headers when your app should appear in rankings.

TypeScript
process.env.ANTHROPIC_BASE_URL = "https://api.therouter.ai";
process.env.ANTHROPIC_AUTH_TOKEN = process.env.THEROUTER_API_KEY ?? "";
process.env.ANTHROPIC_API_KEY = "";

Caveats

Integration note
If variables are partially set, the SDK may attempt direct Anthropic auth. Always set all three variables explicitly.

For production rollouts, pin SDK versions and validate model compatibility in staging before broad rollout.