Skip to main content

rig_core/providers/
mod.rs

1//! Provider integrations included in `rig-core`.
2//!
3//! - Anthropic
4//! - Azure OpenAI
5//! - ChatGPT and GitHub Copilot auth-backed clients
6//! - Cohere
7//! - DeepSeek
8//! - Gemini
9//! - Groq
10//! - Hugging Face
11//! - Hyperbolic
12//! - Llamafile
13//! - MiniMax
14//! - Mira
15//! - Mistral
16//! - Moonshot
17//! - Ollama
18//! - OpenAI
19//! - OpenRouter
20//! - Perplexity
21//! - Together
22//! - Venice
23//! - Voyage AI
24//! - xAI
25//! - Xiaomi MiMo
26//! - Z.ai
27//!
28//! Each provider module defines a `Client` type and model types for the
29//! capabilities it supports. Capability traits such as
30//! [`CompletionClient`](crate::client::CompletionClient) and
31//! [`EmbeddingsClient`](crate::client::EmbeddingsClient) are implemented only
32//! when the provider declares that capability.
33//!
34//! # Provider implementation checklist
35//!
36//! When adding or changing a provider, verify that the integration includes:
37//!
38//! - for OpenAI-chat-compatible APIs: completions driven by
39//!   [`GenericCompletionModel`](crate::providers::openai::completion::GenericCompletionModel)
40//!   via an
41//!   [`OpenAICompatibleProvider`](crate::providers::openai::completion::OpenAICompatibleProvider)
42//!   impl on the provider extension (never a hand-rolled completion model,
43//!   request struct, or message conversion — dialect differences go in the
44//!   trait's hooks);
45//! - public `Client` and `ClientBuilder` aliases with the correct generics,
46//!   including a `ClientBuilder` API-key generic matching `ProviderBuilder::ApiKey`;
47//! - the `Provider`, `ProviderBuilder`, `Capabilities`, and `ProviderClient`
48//!   implementations;
49//! - explicit API-key marker/auth types with redacted debug behavior for
50//!   credential-bearing values;
51//! - model constants where they are useful and current;
52//! - request conversion from Rig request types, such as
53//!   [`CompletionRequest`](crate::completion::CompletionRequest), without
54//!   inventing unsupported provider API fields;
55//! - response conversion into Rig response types, including usage and tool or
56//!   multimodal content where applicable, built through the
57//!   [`CompletionResponse`](crate::completion::CompletionResponse) `new`/`with_*`
58//!   builders rather than a struct literal — the `with_*_finish_reason` setters
59//!   are what apply
60//!   [`FinishReason::reconcile_with_output`](crate::completion::FinishReason::reconcile_with_output);
61//! - a finish-reason mapping covering every value the provider can report,
62//!   with anything unrecognized preserved verbatim in
63//!   [`FinishReason::Other`](crate::completion::FinishReason::Other) rather
64//!   than guessed at;
65//! - a shared conversion (one used by several OpenAI-compatible providers)
66//!   that takes the provider descriptor name as an input instead of hardcoding
67//!   one, so a reused wire type cannot mislabel its provider;
68//! - `raw_completion` and `raw_stream` inherent methods returning the
69//!   provider's own wire types, with the normalized
70//!   [`CompletionModel`](crate::completion::CompletionModel) methods delegating
71//!   to them so there is exactly one request path either way;
72//! - streaming support when the provider supports streaming;
73//! - provider-response error preservation plus `ProviderResponseExt` and
74//!   telemetry fields consistent with nearby providers where applicable;
75//! - unit, cassette, or live-test coverage appropriate to the changed behavior;
76//! - root facade feature/docs updates for companion provider crates; and
77//! - examples and documentation that match the actual API, feature flags, and
78//!   credential requirements.
79//!
80//! # Example
81//! ```no_run
82//! use rig_core::{
83//!     client::{CompletionClient, ProviderClient},
84//!     completion::{AssistantContent, CompletionModel},
85//!     providers::openai,
86//! };
87//!
88//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
89//! // Initialize the OpenAI client
90//! let openai = openai::Client::from_env()?;
91//!
92//! // Create a model and send a low-level completion request.
93//! let model = openai.completion_model(openai::GPT_5_2);
94//! let request = model
95//!     .completion_request("Discuss the fate of Middle Earth.")
96//!     .preamble("\
97//!         You are Gandalf the white and you will be conversing with other \
98//!         powerful beings to discuss the fate of Middle Earth.\
99//!     ".to_string())
100//!     .build();
101//! let response = model.completion(request).await?;
102//! for item in response.choice {
103//!     if let AssistantContent::Text(text) = item {
104//!         println!("{}", text.text);
105//!     }
106//! }
107//! # Ok(())
108//! # }
109//! ```
110pub mod anthropic;
111pub mod azure;
112pub mod chatgpt;
113pub mod cohere;
114pub mod copilot;
115pub mod deepseek;
116pub mod doubleword;
117pub mod gemini;
118pub mod groq;
119pub mod huggingface;
120pub mod hyperbolic;
121pub mod internal;
122pub mod llamafile;
123pub mod minimax;
124pub mod mira;
125pub mod mistral;
126pub mod moonshot;
127pub mod ollama;
128pub mod openai;
129pub mod openrouter;
130pub mod perplexity;
131pub mod together;
132pub mod venice;
133pub mod voyageai;
134pub mod xai;
135pub mod xiaomimimo;
136pub mod zai;