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
//! Prompt-cache observability for LLM APIs.
//!
//! Wrap your LLM call site with a [`CacheTracker`], feed it the [`Usage`]
//! returned by the provider, and get per-call cache hit ratio, cost saved,
//! and regression alerts. Cross-provider (Anthropic, OpenAI, Bedrock).
//!
//! # Quick start
//!
//! ```
//! use cachebench::{CacheTracker, Provider, Usage};
//! use std::time::Duration;
//!
//! let tracker = CacheTracker::new(Provider::Anthropic)
//! .with_alert_threshold(0.6);
//!
//! // After your LLM call:
//! let usage = Usage {
//! input_tokens: 100,
//! cache_read_tokens: 800,
//! cache_creation_tokens: 0,
//! output_tokens: 50,
//! };
//! let metrics = tracker.record("prefix-abc".into(), usage, Duration::from_millis(420));
//! assert_eq!(metrics.hit_ratio(), Some(1.0));
//! ```
pub use crate;
pub use cratefingerprint;