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
102
103
104
105
//! Portable provider resources with exact model selection.
//!
//! The hierarchy is [`Provider`] → [`Model`] → [`Session`]. Import
//! [`ProviderBackend`], [`ModelBackend`], and [`SessionBackend`] to call behavior
//! on supplied handles. Caller implementations use these traits directly with
//! their own associated children; no normalization constructor is required.
//!
//! [`config`] owns credentials and transport settings; [`models`] owns exact
//! model identity and discovery. Requests and returned values live in
//! [`generation`], [`embedding`], [`files`], [`batch`], [`hosted`], and [`session`].
//! Inspect typed failures through [`error`] and health results through [`runtime`].
//!
//! Provider and Model clones share shutdown. Sessions are unique and close by
//! consumption. Keep the runtime driven until accepted cleanup settles.
//!
//! # Local construction
//!
//! Creating a provider and selecting an exact model performs no service request:
//!
//! ```
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> Result<(), providers_kit::KitError> {
//! use providers_kit::{Provider, ProviderBackend, ProviderConfig, ModelBackend, ModelId};
//! use providers_kit::config::{ProviderKind, OllamaConfig, TransportConfig};
//! let provider = Provider::from_config(ProviderConfig::new(
//! ProviderKind::Ollama(OllamaConfig::local()), TransportConfig::default(),
//! ))?;
//! let model = provider.model(ModelId::new("exact-local-model-id")?)?;
//! assert_eq!(model.model_id().as_str(), "exact-local-model-id");
//! provider.shutdown().await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Generation
//!
//! This example requires a running Ollama service with the exact model installed.
//! Selection does not fall back or prove availability; the operation is authoritative.
//!
//! ```no_run
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> Result<(), providers_kit::KitError> {
//! use providers_kit::{Provider, ProviderBackend, ProviderConfig, ModelBackend, ModelId};
//! use providers_kit::config::{ProviderKind, OllamaConfig, TransportConfig};
//! use providers_kit::generation::{GenerateRequest, Message};
//! let provider = Provider::from_config(ProviderConfig::new(
//! ProviderKind::Ollama(OllamaConfig::local()), TransportConfig::default(),
//! ))?;
//! let result = async {
//! let model = provider.model(ModelId::new("exact-local-model-id")?)?;
//! let request = GenerateRequest::new(vec![Message::user_text("Hello")?])?;
//! model.generate(&request).await
//! }.await;
//! let cleanup = provider.shutdown().await;
//! if let Err(error) = &cleanup {
//! eprintln!("Cleanup failed: {error}");
//! }
//! let response = result?;
//! cleanup?;
//! // Preserve response.message unchanged for subsequent function continuation.
//! let _assistant_message = response.message;
//! # Ok(())
//! # }
//! ```
//!
//! # Choose a workflow
//!
//! | Audience | Start here |
//! | --- | --- |
//! | Application builders | [Generation and exact assistant replay](generation), [embeddings](embedding), [owned files](files), [batch lifecycle](batch), and [interactive Sessions](session) |
//! | Custom-backend implementers | The complete local hierarchy on [`ProviderBackend`], then the sessionless [`ModelBackend`] companion |
//!
//! The supplied Session dispatcher supports **OpenAI only**. Supplied Gemini,
//! Anthropic and Ollama Models return Unsupported from `open_session`. Stateless
//! OpenAI audio input/audio-chat models are also unsupported; this does not remove
//! OpenAI Realtime Session support. These supplied-backend restrictions do not
//! constrain an independently implemented [`SessionBackend`].
//!
//! The examples demonstrate API use, not current account/model availability or
//! native qualification. Model ids are exact, and the selected operation decides
//! whether a requested combination is supported.
pub use crateProviderConfig;
pub use crateKitError;
pub use crate;
pub use crate;
pub use crate;