| Crates.io | anthropik |
| lib.rs | anthropik |
| version | 0.1.2 |
| created_at | 2025-12-23 20:12:50.41183+00 |
| updated_at | 2025-12-23 20:56:10.867947+00 |
| description | Anthropic client for Rust. |
| homepage | |
| repository | https://github.com/chaynabors/anthropik |
| max_upload_size | |
| id | 2002234 |
| size | 86,034 |
A Rust client for the Anthropic API, named for my love of pikpik carrots.
This library is functional and actively used in strands-rs, which I develop for fun. If there's interest or need, I'm happy to productionize it further. Open an issue if this would be useful to you.
I wrote this because existing Anthropic clients for Rust lack active maintainers with serious Rust experience, and a client is straightforward to implement and maintain properly.
Alternatives considered:
cargo add anthropik
cargo add anthropik
cargo add tokio --features full
use anthropik::{
AnthropicClient, Content, InputMessage, MessagesRequest,
MessagesRequestBody, Model, Role,
};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = AnthropicClient::new();
let response = client
.messages(&MessagesRequest {
x_api_key: std::env::var("ANTHROPIC_API_KEY")?.into(),
body: MessagesRequestBody {
model: Model::ClaudeSonnet4_5,
messages: vec![InputMessage {
role: Role::User,
content: Content::String("Hello, Claude!".to_string()),
..Default::default()
}],
max_tokens: 1024,
..Default::default()
},
..Default::default()
})
.await?;
println!("Response: {:?}", response);
Ok(())
}
For streaming, use messages_stream() and set stream: true in the request body.
Full API documentation is available on docs.rs.
For Anthropic API details, see the official documentation.
Most structs are marked #[non_exhaustive] to prevent breakage when new API fields are added. This trades some ergonomics (requiring ..Default::default()) for stability as the library approaches 1.0.
Contributions welcome. Open an issue or submit a PR.
Licensed under either of:
at your option.