Expand description
Completion requests, normalized responses, and provider model contracts.
use rig_core::completion::CompletionRequest;
let request = CompletionRequest::new("Who are you?")
.preamble("You are a concise assistant.")
.temperature(0.5);
assert_eq!(request.temperature, Some(0.5));Structs§
- Completion
Request - A completion request to any provider’s model.
- Completion
Response - Assistant content and normalized completion metadata. The choice may be
empty, including for truncated or filtered turns. Provider-specific data is
available through
Self::rawwithout retaining a concrete model type. - Context
Use - The context a conversation’s next request sends, against the model’s window.
- Cost
- What one or more turns cost, in USD.
totalis what was charged, or whenSelf::is_completeisfalse, a lower bound of it. - Document
- A document sent with a request as context, rendered before the chat history.
- Provider
Capabilities - Model capabilities used by runtimes when preparing requests.
Defaults are conservative; construct through
Self::newand setters. - Provider
Tool Definition - Provider-native tool definition.
- Response
Identity - Distinct response and transport identifiers for one model call.
Unreported identifiers remain
None. - Tool
Annotations - What calling a tool does to the world, as the Model Context Protocol’s
tool annotations state it, and spelled as they are on its wire
(
readOnlyHint, …), so an MCP tool’s annotations read straight into one. Each is a hint a tool’s author gives: a host’s policies read them (approval, plan mode, which calls run side by side), never trusting a tool it does not trust for them. A hint left unset takes the protocol’s default, which the accessors apply: not read-only, destructive, not idempotent, open world. - Tool
Definition - A tool the model may call: its name, description and argument schema,
sent to the model, and what the tool does to the world
(
ToolAnnotations), which stays with the host. - Usage
- The token usage a provider reported for one completion.
- Usage
Totals - Many calls’
Usagesummed for a running account: the token counters, the known cost, and how many calls the sum holds and how many of them were not fully priced.
Enums§
- Cache
Point - A point in a
CompletionRequestthat ends a stable prefix, forCompletionRequest::cache_points. Prefixes run in the order a request is sent: tools, then the system prompt, then the messages. - Finish
Reason - Normalized generation ending. Unmapped provider values remain in
Self::Other. Failure statuses may accompany parseable output; callers must decide whether such output is usable rather than treating every response as successful.
Functions§
- tokens_
label - A token count in at most four characters plus a unit:
999,1.2k,45k,1.2M.