1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Messages API client for Claude.
//!
//! This module provides the main interface for interacting with the Anthropic Messages API:
//!
//! - [`request`] - Request types and the [`Messages`](request::Messages) client
//! - [`response`] - Response types including [`Response`](response::Response)
//! - [`streaming`] - SSE streaming support
//!
//! # Basic Usage
//!
//! ```rust,no_run
//! use anthropic_tools::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let mut client = Messages::new();
//! client
//! .model("claude-sonnet-4-20250514")
//! .max_tokens(1024)
//! .system("You are a helpful assistant.")
//! .user("Hello!");
//!
//! let response = client.post().await?;
//! println!("{}", response.get_text());
//! Ok(())
//! }
//! ```
//!
//! # With Tools
//!
//! ```rust,no_run
//! use anthropic_tools::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let mut tool = Tool::new("search");
//! tool.description("Search the web")
//! .add_string_property("query", Some("Search query"), true);
//!
//! let mut client = Messages::new();
//! client
//! .model("claude-sonnet-4-20250514")
//! .max_tokens(1024)
//! .tools(vec![tool.to_value()])
//! .user("Search for Rust programming");
//!
//! let response = client.post().await?;
//! if response.has_tool_use() {
//! // Handle tool use
//! }
//! Ok(())
//! }
//! ```