Expand description
Provider-agnostic completion and chat abstractions.
This module contains the low-level request and response types used by provider
implementations. CompletionModel is the provider-facing trait implemented
by completion models; runtimes build orchestration on top of this boundary.
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::CompletionModel,
providers::openai,
};
let client = openai::Client::from_env()?;
let model = client.completion_model(openai::GPT_5_2);
let request = model.completion_request("What is Rig?").build();
let response = model.completion(request).await?;
println!("{:?}", response.choice);Modules§
Structs§
- Completion
Request - Struct representing a general completion request that can be sent to a completion model provider.
- Completion
Request Builder - Builder struct for constructing a completion request.
- Completion
Response - General completion response struct that contains the high-level completion choice and the raw response. The completion choice contains one or more assistant content.
- Document
- Provider
Tool Definition - Provider-native tool definition.
- Tool
Definition - Usage
- Struct representing the token usage for a completion request.
If tokens used are
0, then the provider failed to supply token usage metrics.
Enums§
- Assistant
Content - Describes responses from a provider which is either text or a tool call.
- Completion
Error - Errors returned by completion models.
- Message
- A provider-agnostic chat message.
- Message
Error - Error type to represent issues with converting messages to and from specific provider messages.
Traits§
- Completion
Model - Trait defining a completion model that can be used to generate completion responses. This trait is meant to be implemented by the user to define a custom completion model, either from a third party provider (e.g.: OpenAI) or a local model.
- GetToken
Usage - A trait for grabbing the token usage of a completion response.