This is an old release — see the latest release for typed structured output, derived tool schemas, and current model ids. Everything below still applies to 0.1.0.
A Rust SDK for Anthropic's Claude API that can't panic on you.
unwrap, expect, panic!, and todo! are denied at compile time in the library. A malformed or unexpected response is always an Error you handle — never a panic in your service.
cargo add crimson-crab
use crimson_crab::model_ids::CLAUDE_OPUS_4_8; use crimson_crab::prelude::*; #[tokio::main] async fn main() -> crimson_crab::Result<()> { let client = Client::from_env()?; // reads ANTHROPIC_API_KEY let request = MessagesRequest::builder() .model(CLAUDE_OPUS_4_8) .max_tokens(1024) .messages(vec![MessageParam::user("Explain Rust's borrow checker in one line.")]) .build()?; println!("{}", client.messages().create(&request).await?.text()); Ok(()) }
Client is Clone + Send + Sync and shares one connection pool — build it once and drop it in your axum state or server struct. No Arc, no Mutex.
What's covered
The full Messages API: streaming (hand-rolled SSE that accumulates to a final Message), tool use, extended thinking, prompt caching, structured outputs, token counting, the Models API, and Message Batches (create / poll / cancel / stream JSONL results).
Three design decisions
Forward-compatible types. Every tagged enum has a catch-all variant and model is an open string, so a new model or a content-block type Anthropic adds is a value you can match on — not a deserialization error, and not a release you have to wait for.
No Tokio in the public API. Streaming returns a plain futures_core::Stream, so it drops into whatever runtime you already run. The crate also compiles to wasm32-unknown-unknown.
Hardened against hostile input. Typed errors per status with retry-after capture, retries with exponential backoff and full jitter matching the official SDKs' policy, capped retry-after, bounded allocations, and an idle-timeout design so streaming is never cut short by a total-request timeout.
Verified in this release
191 tests (wiremock integration suites plus serde round-trips against real API fixtures) · zero clippy warnings on --all-targets --all-features · MSRV 1.75 · MIT OR Apache-2.0.
Links
📖 docs.rs · 📦 crates.io · 🌐 Site · 🦀 MCP server template
Claude-only, and deep on purpose. If you need multi-provider, rig and genai are genuinely good and worth your time.
crimson-crab is an independent open-source project and is not affiliated with Anthropic.