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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! Provider implementations and the low-level streaming event they emit.
//!
//! Each provider module wraps one HTTP API and translates the crate's
//! provider-agnostic [`Prompt`](crate::Prompt)/[`Response`](crate::Response)
//! types to and from that API's wire format. Modules are gated behind the
//! matching Cargo feature (`openai`, `anthropic`, `openrouter`), all of which
//! are enabled by default.
//!
//! `openai_compatible` is the exception to one module per service: it targets
//! the OpenAI Chat Completions *format* as implemented by self-hosted and
//! third-party servers, so the endpoint is named per client. It shares the
//! `openai` feature because it also shares that module's request builder and
//! stream parser.
//!
//! Most code should go through [`Client`](crate::Client) instead of using these
//! types directly; they are public so that advanced callers can drive a single
//! provider, and because streaming surfaces [`ProviderStreamEvent`].
pub use OpenAIProvider;
pub use OpenAICompatibleProvider;
pub use AnthropicProvider;
pub use OpenRouterProvider;
use crateUsage;
/// Build the HTTP client with a deterministic TLS backend.
///
/// Cargo features are additive, so a downstream dependency can enable both
/// reqwest backends even when this crate requested only one. reqwest 0.13
/// otherwise prefers native-tls in that situation. rai-sdk keeps its documented
/// rustls default by selecting rustls explicitly whenever it is available.
pub
/// A low-level event decoded from a provider's server-sent event stream.
///
/// This is the raw shape yielded by
/// [`RequestBuilder::stream`](crate::RequestBuilder::stream). Providers differ
/// in how they chunk tool calls, so tool arguments arrive as a
/// [`ProviderStreamEvent::ToolCallStart`] followed by any number of
/// [`ProviderStreamEvent::ToolCallChunk`]s that must be concatenated. For a
/// pre-assembled view, use
/// [`RequestBuilder::generate_stream_events`](crate::RequestBuilder::generate_stream_events).