Skip to main content

AI Gateway

Route Claude calls through the AI Gateway with a single base URL change. Zero vendor lock-in: always run on the best model at the lowest cost for the use case.

Claude Agent SDK

Building programmable agents with multi-turn conversations, tool use, and MCP servers? Use the Claude Agent SDK instead.

Anthropic Messages API

Endpoint details, authentication, and cache_control breakpoints on the Anthropic-compatible endpoint.

AI Gateway

Overview

The Anthropic SDK (@anthropic-ai/sdk and anthropic) is the native client for the Claude Messages API. Connect it to Toqan Router’s AI Gateway with a single base_url change and no other modifications to existing code, unlocking 500+ models across 30+ providers, fallbacks, caching, and cost tracking.
For programmable agents with multi-turn conversations, tool use, and MCP servers, see the Claude Agent SDK integration.

Key Benefits

Toqan Router’s AI Gateway enhances the Anthropic SDK with:

Complete Observability

Track every API call, token usage, and model interaction with detailed traces and analytics

Built-in Reliability

Automatic fallbacks, retries, and load balancing for production resilience

Cost Optimization

Real-time cost tracking and spend management across all AI operations

Multi-Provider Access

Access 500+ LLMs and 30+ providers through a single, unified integration

Prerequisites

Before integrating the Anthropic SDK with Toqan Router, ensure the following are in place:
  • A Toqan Router account and API Key
  • Python 3.8+ or Node.js 18+ with TypeScript support
  • Anthropic SDK installed
To set up an API key, see API keys & Endpoints.

Installation

Configuration

Set the Base URL to the AI Gateway and authenticate with a Toqan Router API key to route calls through the API without changing any other part of the code.
base_url: https://router.toqan.ai/eu/v3/anthropic

Text Generation

Basic text generation with the Anthropic SDK through Toqan Router:

Streaming

Stream responses for real-time output:

Tool Use

Define tools and let the model decide when to call them. The AI Gateway forwards tool definitions and returns tool_use blocks unchanged:

Model Selection

The anthropic/ prefix routes to Claude models. Switch to any supported model from 30+ providers by changing the model value:
Browse every available model in Supported Models.