| Crates.io | turboclaude |
| lib.rs | turboclaude |
| version | 0.3.0 |
| created_at | 2025-11-02 05:34:31.66244+00 |
| updated_at | 2026-01-08 03:22:01.629177+00 |
| description | Unofficial Rust SDK for Anthropic's Claude API with 100% feature parity to official Python SDK |
| homepage | |
| repository | https://github.com/epistates/turboclaude |
| max_upload_size | |
| id | 1912698 |
| size | 1,086,539 |
Rust SDK for Anthropic's Claude API with support for multi-cloud providers (AWS Bedrock, Google Vertex AI), agent framework, and tool system.
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(())
}
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:
schema feature in Cargo.tomlCLAUDE_SONNET_4_5_20250929_STRUCTURED_OUTPUTSSerialize, Deserialize, and JsonSchema for your output typeSee examples/structured_outputs.rs for more examples.
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!
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!
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 blockingTurboClaude is built on a modular architecture:
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 (requires schema feature)bedrock_basic.rs - AWS Bedrock usagevertex_basic.rs - Google Vertex AI usageRun examples with:
cargo run --example basic --features env,trace
# Run all tests
cargo test --all
# Run with output
cargo test --all -- --nocapture
# Run specific test
cargo test --lib test_name
cargo doc --openTurboClaude is optimized for production:
v0.1.0 - All tests passing. See main README for test results.
MIT/Apache-2.0
Contributions welcome! Please see CONTRIBUTING.md (when created).
For issues and feature requests, see the GitHub repository.
Part of the TurboClaude Rust Ecosystem