Expand description
Provider-agnostic completion and chat abstractions.
This module contains the low-level request and response types used by provider
implementations, plus the high-level traits most callers use through
Agent:
Promptsends one user prompt and returns assistant text.Chatsends a prompt with existing history and returns assistant text.TypedPromptrequests structured output and deserializes it into a Rust type.Completionexposes a request builder for call-site overrides.CompletionModelis the provider-facing trait implemented by completion models.
CompletionRequest is Rig’s canonical request representation. Provider modules
translate it into provider-specific request bodies and convert responses back into
CompletionResponse.
§Example
use rig_core::{
client::{CompletionClient, ProviderClient},
completion::Prompt,
providers::openai,
};
let client = openai::Client::from_env()?;
let agent = client
.agent(openai::GPT_5_2)
.preamble("Answer concisely.")
.build();
let answer = agent.prompt("What is Rig?").await?;
println!("{answer}");Re-exports§
pub use message::AssistantContent;pub use message::Message;pub use message::MessageError;pub use request::*;