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
//! Unified AI client.
//!
//! Wraps [`genai`] for the multi-provider mainstream (`OpenAI` /
//! Gemini / Ollama / OpenAI-compatible) and drops down to a direct
//! `reqwest`-on-Anthropic-Messages path for features `genai` does not
//! yet surface — prompt caching, extended thinking, citations.
//!
//! Structured output uses `schemars::JsonSchema` on caller-supplied
//! types: the schema is sent with the request, and the response is
//! validated with `jsonschema` before deserialising.
//!
//! See `docs/development/specs/2026-05-01-rtb-ai-v0.1.md` for the
//! authoritative contract.
//!
//! # Lint exception
//!
//! Crate-level `deny(unsafe_code)` (not `forbid`) so the genai-key
//! shim in [`client`] can locally `allow(unsafe_code)` the
//! `std::env::set_var` it needs to hand the API key to genai. No
//! hand-rolled `unsafe` blocks anywhere else.
// Token counts cross the u64 (provider response) ↔ u32 (Usage)
// boundary frequently; the saturating defaults are intentional.
// The Anthropic helpers are `pub(crate)` for the `test_hooks` re-
// export pattern; clippy's `redundant_pub_crate` is overzealous here.
pub
pub use ;
pub use ;
pub use AiError;
pub use ;
pub use ThinkingMode;
/// Internal hooks exposed for unit-test reach-throughs. Not part of
/// the stable public API and may change between minor releases.