Expand description
§Anthropic Rust SDK
A modern Rust SDK for the Anthropic API, providing type-safe, async-first access to Claude models.
§Quick Start
use anthropic_rust::{Client, Model, ContentBlock};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new(Model::Claude35Sonnet20241022)?;
let request = client.chat_builder()
.user_message(ContentBlock::text("Hello, Claude!"))
.build();
let response = client.execute_chat(request).await?;
println!("Response: {:?}", response);
Ok(())
}Re-exports§
pub use client::Client;pub use client::LoggingInterceptor;pub use client::RequestInterceptor;pub use client::RequestMiddleware;pub use client::RetryConfig;pub use config::ClientBuilder;pub use config::Config;pub use error::Error;pub use streaming::ContentDelta;pub use streaming::MessageAccumulator;pub use streaming::MessageDelta;pub use streaming::MessageStream;pub use streaming::PartialMessage;pub use streaming::StreamEvent;pub use tools::Tool;pub use tools::ToolBuilder;pub use types::ChatRequest;pub use types::ChatRequestBuilder;pub use types::ContentBlock;pub use types::CountTokensRequest;pub use types::DocumentMediaType;pub use types::DocumentSource;pub use types::ImageMediaType;pub use types::ImageSource;pub use types::Message;pub use types::MessageParam;pub use types::Model;pub use types::Role;pub use types::StopReason;pub use types::SystemMessage;pub use types::TokenCount;pub use types::Usage;pub use multimodal::validate_url;pub use multimodal::Base64Utils;pub use multimodal::DocumentUtils;pub use multimodal::ImageUtils;pub use multimodal::MimeUtils;
Modules§
- client
- Client implementation for the Anthropic API
- config
- Configuration and builder patterns for the Anthropic client
- error
- Error types for the Anthropic SDK
- multimodal
- Multimodal content handling utilities
- streaming
- Streaming support for the Anthropic API
- tools
- Tool calling functionality for the Anthropic API
- types
- Core types and data models for the Anthropic API.
Macros§
- tool
- Convenience macro for tool definition
Type Aliases§
- Result
- Result type alias for the SDK