Skip to main content
The Anthropic SDK provides official Python and TypeScript clients for interacting with Claude models. Edgee’s Anthropic-compatible API works seamlessly with the Anthropic SDK, allowing you to leverage the SDK’s features while gaining access to Edgee’s unified gateway, automatic failover, and full observability.

Installation

Basic Usage

Streaming Responses

Stream responses for real-time token delivery:

Token Usage Tracking

Access standard Anthropic token usage metrics in every response:
When compression is enabled, input_tokens reflects the compressed token count. View detailed compression metrics in the Edgee dashboard.

Compression & Tags via Headers

When using the Anthropic SDK with Edgee, you can control token compression and add tags using HTTP headers:

Enabling Compression

The headers below control Token Compression.

Adding Tags for Analytics

Combine compression with tags to track requests in your dashboard:
Available Headers:
You can also enable compression per API key or Agent in the Edgee console. Headers override console settings for specific requests.

Multi-Provider Access

With Edgee, you can access models from multiple providers using the same Anthropic SDK client and compare costs across providers:

Function Calling (Tools)

Use Claude’s tool calling with Edgee:

Error Handling and Retries

The Anthropic SDK includes built-in retry logic, which works seamlessly with Edgee’s automatic failover:

Complete Example

Here’s a complete application example: