3 releases (breaking)
Uses new Rust 2024
| 0.3.0 | Jan 8, 2026 |
|---|---|
| 0.2.0 | Dec 5, 2025 |
| 0.1.0 | Nov 2, 2025 |
#1866 in Asynchronous
Used in turboclaudeagent
1MB
16K
SLoC
TurboClaude Rust SDK
Rust SDK for Anthropic's Claude API with support for multi-cloud providers (AWS Bedrock, Google Vertex AI), agent framework, and tool system.
Features
Supported Providers
- Anthropic (official API)
- AWS Bedrock
- Google Vertex AI
API Coverage
- Messages API with streaming
- Batch processing
- Tool use and function calling
- Structured outputs (beta) with type-safe JSON parsing
- Prompt caching
- Document and PDF analysis
- Vision capabilities
- Token counting
- Models API
Agent Framework
- Agent client and configuration
- Message hooks and interception
- Permission system
- Message routing
- Skills integration
Tools & Extensions
- Custom tool definitions
- Computer use (beta)
- Bash execution (beta)
- Web search (beta)
- Code execution (beta)
Advanced Features
- Real-time streaming
- Prompt caching for cost reduction
- Persistent memory (beta)
- Extended thinking (beta)
Quick Start
use turboclaude::Client;
use turboclaude::types::{MessageRequest, Message};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client (uses ANTHROPIC_API_KEY environment variable)
let client = Client::new("sk-ant-...");
// Send a message
let response = client.messages()
.create(MessageRequest::builder()
.model(turboclaude::types::Models::CLAUDE_SONNET_4_5)
.max_tokens(1024u32)
.messages(vec![Message::user("Hello, Claude!")])
.build()?)
.await?;
// Print response
for content in response.content {
if let turboclaude::types::ContentBlock::Text { text, .. } = content {
println!("{}", text);
}
}
Ok(())
}
Structured Outputs (Beta)
Get type-safe JSON responses that match a predefined schema:
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use turboclaude::{Client, Message};
use turboclaude_protocol::types::models;
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct Order {
product_name: String,
price: f64,
quantity: u32,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new("sk-ant-...");
// Use .parse::<T>() for type-safe structured outputs
let parsed = client
.beta()
.messages()
.parse::<Order>()
.model(models::CLAUDE_SONNET_4_5_20250929_STRUCTURED_OUTPUTS.to_string())
.messages(vec![Message::user(
"Extract order: '3 Green Tea boxes at $15.99 each'"
)])
.max_tokens(1024)
.send()
.await?;
// Automatically parsed and validated!
let order = parsed.parsed_output()?;
println!("Product: {}, Price: ${}, Qty: {}",
order.product_name, order.price, order.quantity);
Ok(())
}
Requirements:
- Enable the
schemafeature in Cargo.toml - Use the structured outputs model:
CLAUDE_SONNET_4_5_20250929_STRUCTURED_OUTPUTS - Derive
Serialize,Deserialize, andJsonSchemafor your output type
See examples/structured_outputs.rs for more examples.
Multi-Cloud Usage
AWS Bedrock
use turboclaude::{Client, providers::bedrock::BedrockHttpProvider};
use std::sync::Arc;
let provider = Arc::new(
BedrockHttpProvider::builder()
.region("us-east-1")
.build()
.await?
);
let client = Client::from_provider(provider);
// Use same client API!
Google Vertex AI
use turboclaude::{Client, providers::vertex::VertexHttpProvider};
use std::sync::Arc;
let provider = Arc::new(
VertexHttpProvider::builder()
.project_id("my-gcp-project")
.region("us-east5")
.access_token(token)
.build()
.await?
);
let client = Client::from_provider(provider);
// Use same client API!
Features & Flags
Enable optional functionality via Cargo features:
[dependencies]
turboclaude = { version = "0.2", features = ["bedrock", "vertex", "schema"] }
Available features:
env: Load API key from environment variables (default)bedrock: AWS Bedrock provider supportvertex: Google Vertex AI provider supportschema: JSON schema generation for toolsmcp: Model Context Protocol integrationtrace: Tracing/logging supportfull: All features except blocking
Architecture
TurboClaude is built on a modular architecture:
- turboclaude: Main SDK with multi-cloud providers
- turboclaude-transport: HTTP and subprocess transport
- turboclaude-protocol: Protocol types and messages
- turboclaude-core: Core abstractions and traits
- turboclaudeagent: Agent framework with hooks/permissions
- turboclaude-skills: Skills system for dynamic capabilities
- turboclaude-mcp: Model Context Protocol integration
Examples
Check the examples/ directory for:
basic.rs- Simple message sendingstreaming.rs- Real-time streamingtools.rs- Tool use and function callingstructured_outputs.rs- Type-safe JSON parsing (requiresschemafeature)bedrock_basic.rs- AWS Bedrock usagevertex_basic.rs- Google Vertex AI usage- And more...
Run examples with:
cargo run --example basic --features env,trace
Testing
# Run all tests
cargo test --all
# Run with output
cargo test --all -- --nocapture
# Run specific test
cargo test --lib test_name
Documentation
- Full API documentation:
cargo doc --open - Architecture guide: See module-level documentation
- Implementation details: Check individual crate READMEs
Performance
TurboClaude is optimized for production:
- Zero-copy message handling
- Streaming support to reduce memory
- Configurable timeouts and retries
- Connection pooling via reqwest
Status
v0.1.0 - All tests passing. See main README for test results.
License
MIT/Apache-2.0
Contributing
Contributions welcome! Please see CONTRIBUTING.md (when created).
Support
For issues and feature requests, see the GitHub repository.
Part of the TurboClaude Rust Ecosystem
Dependencies
~21–45MB
~634K SLoC