Anthropic Claude API Client for Rust
Production-ready Rust client for Anthropic's Claude API with 83% feature coverage
A comprehensive, feature-rich HTTP client for interacting with Anthropic's Claude API. Built with safety, performance, and developer experience in mind.
โจ Features
- ๐ฌ Messages API - Full conversational interface support
- ๐พ Prompt Caching - ~90% cost savings with Anthropic's caching
- ๐ก Streaming - Server-Sent Events (SSE) streaming responses
- ๐ ๏ธ Tool Calling - Complete function calling and tool integration
- ๐ผ๏ธ Vision Support - Image analysis capabilities
- ๐ Enterprise Ready - Rate limiting, retries, circuit breaker, failover
- ๐ Rich Diagnostics - Curl command generation and detailed error context
- ๐ Sync & Async APIs - Both synchronous and asynchronous interfaces
๐ Quick Start
Add to your Cargo.toml:
[]
= { = "0.1.0", = ["full"] }
Basic Usage
use ;
async
๐ง Configuration
Set your API key via environment variable:
Or use workspace secrets (see Secret Loading Guide).
๐ Documentation
- API Reference - Complete API documentation
- Examples - Real-world usage examples
- Testing Guide - Testing organization and NO MOCKING policy
- Secret Loading - Authentication and secret management
- Specification - Detailed project specification
๐๏ธ Project Structure
api_claude/
โโโ src/ # Library source code
โโโ tests/ # Comprehensive test suite (435 tests)
โโโ examples/ # Usage demonstrations
โโโ docs/ # Architecture and design documentation
โโโ spec.md # Project specification
๐งช Testing
# Run all tests
# Run with linting
# Documentation tests
โ ๏ธ Note: Integration tests require valid ANTHROPIC_API_KEY and use real API calls (NO MOCKING).
๐ง Building
# Build with all features
# Build for release
๐ Feature Flags
Fine-grained control via feature flags:
authentication- API key managementrate-limiting- Token bucket rate limitingretry-logic- Request retry mechanismscircuit-breaker- Circuit breaker patternstreaming- SSE streaming supportfull- All features enabled
See Cargo.toml for complete list.
๐ License
This project is licensed under the MIT License.
๐ค Contributing
Contributions welcome! Please ensure all tests pass before submitting PR.