Skip to main content

rig_core/completion/
mod.rs

1//! Provider-agnostic completion requests and responses. A provider's wire
2//! translates [`CompletionRequest`] into its own request and normalizes the
3//! reply as [`CompletionResponse`]; a [`Model`](crate::Model) sends it.
4//!
5//! ```no_run
6//! use rig_core::{Model, completion::CompletionRequest, providers::openai::OpenAIConfig};
7//!
8//! # async fn run(http: rig_core::http_client::DynHttpClient) -> Result<(), Box<dyn std::error::Error>> {
9//! let model = OpenAIConfig::from_env()?.connect(http).completion("gpt-4o");
10//! let request = CompletionRequest::new("What is Rig?");
11//! let response = model.call(request).await?;
12//! println!("{:?}", response.choice);
13//! # Ok(())
14//! # }
15//! ```
16
17pub mod cache_cost;
18pub mod handle;
19pub mod history;
20pub mod message;
21pub mod options;
22pub mod prompt;
23pub mod provider_options;
24pub mod request;
25
26pub use cache_cost::{CacheCost, CacheRates};
27pub use handle::ModelRef;
28pub use history::{Accepts, LaterSystem, Media, Pairing, Place, Replay, ReplayTarget, adapt};
29pub use message::{AssistantContent, AssistantMessage, Message, MessageError};
30pub use options::{
31    CacheRetention, CheckError, Effort, GenerationOptions, OnUnsupported, Reasoning, ServiceTier,
32    UnsupportedOption, Verbosity,
33};
34pub use prompt::{Section, SystemPrompt};
35pub use provider_options::{
36    ExtensionOptions, OptionsError, ProviderExtension, ProviderOptions, ReplyExtras, SHARED,
37};
38pub use request::*;