Skip to main content

agent_sdk/
lib.rs

1//! # Agent SDK - Claude Agent SDK for Rust
2//!
3//! Build production AI agents with Claude. This is a Rust port of the
4//! [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview).
5//!
6//! ## Quick Start
7//!
8//! ```rust,no_run
9//! use agent_sdk::{query, Options, Message};
10//! use tokio_stream::StreamExt;
11//!
12//! #[tokio::main]
13//! async fn main() -> anyhow::Result<()> {
14//!     let mut stream = query(
15//!         "What files are in this directory?",
16//!         Options::builder()
17//!             .allowed_tools(vec!["Bash".into(), "Glob".into()])
18//!             .build(),
19//!     );
20//!
21//!     while let Some(message) = stream.next().await {
22//!         let message = message?;
23//!         if let Message::Result(result) = &message {
24//!             println!("{}", result.result.as_deref().unwrap_or(""));
25//!         }
26//!     }
27//!     Ok(())
28//! }
29//! ```
30
31pub mod client;
32pub mod compact;
33pub mod error;
34pub mod hooks;
35pub mod mcp;
36pub mod models;
37pub mod options;
38pub mod permissions;
39pub mod provider;
40
41/// Backward-compatible alias for `models`.
42pub mod pricing {
43    pub use crate::models::*;
44}
45pub mod providers;
46pub mod query;
47pub mod sanitize;
48pub mod session;
49pub mod tools;
50pub mod types;
51
52// Re-export main public API
53pub use error::AgentError;
54pub use hooks::{
55    hook_fn, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookOutput, HookRegistry,
56};
57pub use mcp::{McpHttpServerConfig, McpServerConfig, McpSseServerConfig, McpStdioServerConfig};
58pub use models::{ModelRegistry, PricingRegistry};
59pub use options::{
60    CustomToolDefinition, ExternalToolHandlerFn, Options, OptionsBuilder, PermissionMode,
61    PreCompactHandlerFn, QueryAttachment,
62};
63pub use provider::{CostRates, LlmProvider, ProviderCapabilities};
64pub use providers::{
65    AnthropicProvider, BedrockProvider, GeminiProvider, OllamaDiscovery, OpenAiProvider,
66    VertexProvider,
67};
68pub use query::{query, Query};
69pub use session::{Session, SessionInfo};
70pub use tools::executor::ToolResult;
71pub use types::agent::{AgentDefinition, AgentInput};
72pub use types::messages::*;
73pub use types::tools::*;