AI Gateway
Overview
The Anthropic SDK (@anthropic-ai/sdk and anthropic) is the native client for the Claude Messages API. Connecting it to Orq.ai’s AI Gateway with a single base_url change unlocks 300+ models across 20+ providers, fallbacks, caching, and cost tracking, with no other modifications to existing code.
For programmable agents with multi-turn conversations, tool use, and MCP servers, see the Claude Agent SDK integration.
Key Benefits
Orq.ai’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 300+ LLMs and 20+ providers through a single, unified integration
Prerequisites
Before integrating the Anthropic SDK with Orq.ai, ensure the following are in place:- An Orq.ai 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 an Orq.ai API key to route calls through the API without changing any other part of the code.
base_url: https://api.orq.ai/v3/anthropic
Text Generation
Basic text generation with the Anthropic SDK through Orq.ai: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 returnstool_use blocks unchanged:
Model Selection
Theanthropic/ prefix routes to Claude models. Switch to any supported model from 20+ providers by changing the model value:
Browse every available model in Supported Models.