Expand description
§TurboClaude SDK
Rust SDK for Anthropic’s Claude API supporting:
- Messages API with streaming
- Batch processing
- Tool use and function calling
- Multi-cloud providers (Anthropic, AWS Bedrock, Google Vertex AI)
- Multiple authentication methods
- Automatic retries and rate limiting
§Quick Start
use turboclaude::{Client, Message, MessageRequest};
use turboclaude_protocol::types::models;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new("your-api-key");
let message = client.messages()
.create(MessageRequest::builder()
.model(models::CLAUDE_SONNET_4_5_20250514)
.max_tokens(1024u32)
.messages(vec![
Message::user("Hello, Claude!")
])
.build()?)
.await?;
println!("{}", message.text());
Ok(())
}Re-exports§
pub use client::Client;pub use config::ClientConfig;pub use context::AdaptiveStrategy;pub use context::PruningPolicy;pub use error::Error;pub use error::Result;pub use http::RawResponse;pub use resources::BatchRequest;pub use resources::TokenCount;pub use types::*;
Modules§
- client
- Main client implementation for the Anthropic API
- config
- Configuration for the Anthropic client
- context
- Adaptive context management with token-aware pruning
- error
- Error types for the Anthropic SDK
- http
- HTTP client abstraction and middleware
- observability
- Centralized observability utilities for structured logging and metrics
- prelude
- Prelude module for common imports
- resources
- API resource endpoints
- streaming
- Streaming support for the Messages API
- streaming_
validation - Streaming event validation for message streams
- types
- Core types for the Anthropic API
- validation
- Request validation for the Anthropic SDK
Enums§
- Json
Value - Represents any valid JSON value.
Constants§
- AI_
PROMPT - Legacy AI prompt constant (for compatibility)
- DEFAULT_
API_ VERSION - Default API version header value
- DEFAULT_
BASE_ URL - Default API base URL
- HUMAN_
PROMPT - Legacy human prompt constant (for compatibility)
- VERSION
- SDK version, automatically updated from Cargo.toml
Traits§
- Deserialize
- A data structure that can be deserialized from any data format supported by Serde.
- Serialize
- A data structure that can be serialized into any data format supported by Serde.