anthropic-rs-sdk
Status: v0.1 — non-streaming Messages API only. This crate is an early port of the official Anthropic Go SDK to Rust. See
ROADMAP.mdfor the full feature checklist.
Async Rust SDK for the Anthropic API. Built on reqwest + tokio, with a
typed request/response model, forward-compatible enums, redacted credentials,
and wiremock-driven tests so CI never touches the real API.
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
The library name is anthropic, so use anthropic::Client works regardless
of the crate name on crates.io.
Quickstart
use ;
async
Run the bundled examples:
ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_API_KEY=sk-ant-...
What's in v0.1
Client::from_env()— readsANTHROPIC_API_KEY(+ optionalANTHROPIC_BASE_URL)Client::builder()— explicitapi_key,base_url,timeout,http_clientmessages.create— non-streaming, with multi-turnVec<InputMessage>- Model constants for the current Claude family (Opus 4.7, Sonnet 4.6, Haiku 4.5, plus dated variants and the older 4.x line)
Model::custom("...")escape hatch for unknown IDs- Typed
ErrorwithError::Api { status, error_type, message, request_id, raw } request-idpreserved on every error responsesecrecy::SecretString-wrapped API key with redactedDebug- 21 tests passing — 14 serde round-trips, 4 wiremock end-to-end, 3 doctests
- Live-API integration test gated by
--features live-tests
What's not in v0.1
Streaming, tool use, multimodal (image / PDF), files, message batches, the
beta surface (agents / sessions / memory / skills / vault / user profiles),
Bedrock + Vertex providers, retries with backoff. Each of these has a tracked
checkbox in ROADMAP.md — the goal is full
Go SDK parity by v1.0.
Cargo features
| Feature | Default | Effect |
|---|---|---|
rustls-tls |
yes | TLS via rustls. Pure Rust, easy cross-compile. |
native-tls |
no | TLS via the OS trust store. Mutually exclusive with above. |
streaming |
no | (Reserved) SSE streaming support. Lands in v0.2. |
tools |
no | (Reserved) Tool-use helpers. Lands in v0.2. |
bedrock |
no | (Reserved) AWS Bedrock provider. Lands in v0.4. |
vertex |
no | (Reserved) Google Vertex AI provider. Lands in v0.4. |
live-tests |
no | Enables tests/messages_live.rs against the real API. |
Verification
RUSTDOCFLAGS="-D warnings"
ANTHROPIC_API_KEY=sk-ant-...
Project conventions
Contributor-facing conventions live in CLAUDE.md: error
handling, async rules, secrets handling, testing strategy, dependency hygiene.
License
MIT — see LICENSE.
Why "anthropic-rs-sdk"?
anthropic, anthropic-sdk, and anthropic-rs were all taken on crates.io
by stale community crates last updated in 2024 (none of which support the
Claude 4 family). anthropic-rs-sdk keeps the convention close to
anthropic-sdk-go while making it obvious this is the Rust port.