Skip to main content

aigw_anthropic/
lib.rs

1//! Anthropic API client for the AI Gateway.
2//!
3//! This crate provides a typed Rust client for the [Anthropic API](https://docs.anthropic.com/en/api/messages),
4//! including non-streaming and SSE streaming support.
5//!
6//! # Features
7//!
8//! - **`claude-code`** — Enables non-standard endpoints used by Claude Code
9//!   (`/api/event_logging/batch`, `/v1/oauth/token`).
10//!
11//! # Quick Start
12//!
13//! ```no_run
14//! use aigw_anthropic::{Client, Transport, TransportConfig, MessagesRequest, Message, MessageContent, Role};
15//! use secrecy::SecretString;
16//!
17//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
18//! let transport = Transport::new(TransportConfig {
19//!     api_key: SecretString::from("sk-ant-..."),
20//!     ..Default::default()
21//! })?;
22//! let client = Client::new(transport)?;
23//!
24//! let req = MessagesRequest::builder()
25//!     .model("claude-sonnet-4-20250514")
26//!     .messages(vec![Message {
27//!         role: Role::User,
28//!         content: MessageContent::Text("Hello, Claude!".into()),
29//!     }])
30//!     .max_tokens(1024)
31//!     .build();
32//!
33//! let resp = client.messages(&req).await?;
34//! println!("{}", resp.body.id);
35//! # Ok(())
36//! # }
37//! ```
38
39pub mod client;
40pub mod error;
41pub mod rate_limit;
42pub mod streaming;
43pub mod translate;
44pub mod transport;
45pub mod types;
46
47pub use client::Client;
48pub use error::Error;
49pub use rate_limit::{ApiResponse, RateLimitInfo};
50pub use transport::{AuthMode, Transport, TransportConfig, TransportConfigError};
51pub use types::*;