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
//! The Batches API: submit a batch of message requests, poll for
//! completion, stream per-request results.
//!
//! Anthropic's batch endpoint is the cheapest way to run large fan-out
//! workloads (50% off vs. per-request pricing) at the cost of higher
//! latency. This module wraps the full surface:
//!
//! - [`Batches::create`] -- submit
//! - [`Batches::get`] -- status (polling-friendly)
//! - [`Batches::list`] / [`Batches::list_all`] -- enumerate
//! - [`Batches::cancel`], [`Batches::delete`]
//! - [`Batches::wait_for`] -- poller that returns once `ended_at` is set
//! - [`Batches::results`] / [`Batches::results_stream`] -- decode the JSONL
//! results body, eagerly into a `Vec` or lazily as a `Stream`
//!
//! The batch ID is the only state you need to durably persist; reattach
//! later by calling [`Batches::get(id)`](Batches::get) or
//! [`Batches::wait_for(id, _)`](Batches::wait_for).
//!
//! # Quick start
//!
//! ```no_run
//! use claude_api::{Client, batches::{BatchRequest, BatchResultPayload, WaitOptions},
//! messages::CreateMessageRequest, types::ModelId};
//! # async fn run() -> Result<(), claude_api::Error> {
//! let client = Client::new(std::env::var("ANTHROPIC_API_KEY").unwrap());
//! let requests = vec![
//! BatchRequest::new("q1",
//! CreateMessageRequest::builder()
//! .model(ModelId::HAIKU_4_5).max_tokens(32).user("2 + 2?").build()?),
//! ];
//! let batch = client.batches().create(requests).await?;
//! let finished = client.batches()
//! .wait_for(&batch.id, WaitOptions::default()).await?;
//! let items = client.batches().results(&finished.id).await?;
//! for item in &items {
//! if let BatchResultPayload::Succeeded { message } = &item.result {
//! println!("{}: {} tokens", item.custom_id, message.usage.output_tokens);
//! }
//! }
//! # Ok(())
//! # }
//! ```
pub use ;
pub use Batches;