Installation
- Python
- TypeScript
Basic Usage
- Python
- TypeScript
Streaming Responses
Stream responses for real-time token delivery:- Python
- TypeScript
Token Usage Tracking
Access standard Anthropic token usage metrics in every response:- Python
- TypeScript
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
- Python
- TypeScript
Adding Tags for Analytics
Combine compression with tags to track requests in your dashboard:- Python
- TypeScript
| Header | Type | Description |
|---|---|---|
x-edgee-enable-compression | "true" or "false" | Enable token compression for requests (overrides console settings) |
x-edgee-compression-rate | string | Target compression rate (0.0-1.0, default 0.75) |
x-edgee-tags | string | Comma-separated tags for analytics and filtering |
Multi-Provider Access
With Edgee, you can access models from multiple providers using the same Anthropic SDK client and compare costs across providers:- Python
- TypeScript
Function Calling (Tools)
Use Claude’s tool calling with Edgee:- Python
- TypeScript
Error Handling and Retries
The Anthropic SDK includes built-in retry logic, which works seamlessly with Edgee’s automatic failover:- Python
- TypeScript
Authentication
Edgee uses standard Bearer token authentication. Set your API key as an environment variable:.env file:
Benefits of Using Anthropic SDK with Edgee
Up to 50% Cost Reduction
Automatic token compression on every request reduces input tokens by up to 50% while preserving output quality.
Multi-Provider Cost Comparison
Compare costs across Claude, GPT-4, Mistral, and 200+ models. Track compression savings per provider.
Automatic Failover
If Claude is rate-limited or unavailable, Edgee automatically routes to backup models without code changes.
Full Observability
Monitor latency, token usage, compression ratios, error rates, and costs for all requests in one dashboard.
Complete Example
Here’s a complete application example:- Python
- TypeScript
Next Steps
- Explore Anthropic SDK documentation for advanced features
- Check out Edgee’s routing capabilities for intelligent model selection
- Set up observability to monitor your applications
- Configure privacy controls to manage data retention