anthropic_async/lib.rs
1#![deny(warnings)]
2#![deny(clippy::all)]
3#![deny(missing_docs)]
4
5//! # `anthropic-async`
6//!
7//! A production-ready Anthropic API client for Rust with prompt caching support.
8//!
9//! ## Quick Start
10//!
11//! ```no_run
12//! use anthropic_async::{Client, types::{content::*, messages::*}};
13//!
14//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
15//! let client = Client::new();
16//!
17//! let req = MessagesCreateRequest {
18//! model: "claude-3-5-sonnet".into(),
19//! max_tokens: 100,
20//! messages: vec![MessageParam {
21//! role: MessageRole::User,
22//! content: "Hello!".into(),
23//! }],
24//! system: None,
25//! temperature: None,
26//! stop_sequences: None,
27//! top_p: None,
28//! top_k: None,
29//! metadata: None,
30//! tools: None,
31//! tool_choice: None,
32//! };
33//!
34//! let response = client.messages().create(req).await?;
35//! # Ok(())
36//! # }
37//! ```
38//!
39//! ## Authentication
40//!
41//! The client supports API key and bearer token authentication.
42//! See [`AnthropicConfig`] for configuration options.
43//!
44//! ## Prompt Caching
45//!
46//! Use [`CacheControl`](types::common::CacheControl) to cache prompts and reduce costs.
47
48/// HTTP client implementation
49pub mod client;
50/// Configuration types for the client
51pub mod config;
52/// Error types
53pub mod error;
54/// API resource implementations
55pub mod resources;
56/// Retry logic utilities
57pub mod retry;
58/// Server-sent events (streaming) support
59#[cfg(feature = "streaming")]
60pub mod sse;
61/// Hidden SSE module when streaming is not enabled
62#[cfg(not(feature = "streaming"))]
63pub(crate) mod sse;
64/// Test support utilities (for use in tests)
65#[doc(hidden)]
66pub mod test_support;
67/// Request and response types
68pub mod types;
69
70pub use crate::client::Client;
71pub use crate::config::{AnthropicAuth, AnthropicConfig, BetaFeature};
72pub use crate::error::{AnthropicError, ApiErrorObject};
73
74/// Prelude module for convenient imports
75pub mod prelude {
76 pub use crate::types::common::*;
77 pub use crate::types::messages::*;
78 pub use crate::types::models::*;
79 pub use crate::{AnthropicConfig, Client};
80}