Expand description
Portable generation options: provider-neutral knobs a request sets once
and every completion wire maps to its own JSON, or refuses. They hold only
what CompletionRequest has no field for, so
temperature, max_tokens, tool_choice and output_schema stay on the
request.
use rig_core::completion::{CacheRetention, CompletionRequest, Effort, GenerationOptions};
let options = GenerationOptions::default()
.reasoning(Effort::High)
.cache(CacheRetention::Long);
let request = CompletionRequest::new("Plan the refactor.").options(options);
assert!(!request.options.is_default());Structs§
- Base
Input - The base builder’s view of the options and the layers above it. It cannot write them.
- Final
Body - The merged request body. Its field is private to this module, so only
request_paramsbuilds one, and nothing writes to it afterwards.Serializeis for wires that hand their SDK the body as bytes. - Generation
Options - Provider-neutral generation knobs for one request. An unset field leaves
the provider’s default. A field the wire or model cannot honour is
reported through
Self::unsupported_policy, never silently dropped. - Option
Fields - Every option but the policy, borrowed, as a wire’s
map_optionsreads it. Not#[non_exhaustive], so wires in companion crates destructure it whole, which#[non_exhaustive]forbids forGenerationOptions. - Option
Map - One
Mappingper option, by field name. Not#[non_exhaustive]and noDefault, so a wire writes every field. - Unsupported
Option - An option the wire or model cannot honour. Carried by
ProviderError::UnsupportedOption.
Enums§
- Cache
Retention - How long the provider keeps the prompt prefix cached.
- Effort
- A portable reasoning effort level, lowest first.
- Mapping
- What a wire does with one option.
- OnUnsupported
- What happens to an option the wire or model cannot honour.
- RawAt
- Where the raw layer,
additional_params, merges. Data, not code. - Reasoning
- How much the model reasons before answering.
- Rewrite
- The writes
request_paramsmakes after the merge, each one a write a wire made after mergingadditional_paramsbefore. Each reads the merged body, raw keys included. A third-party wire uses the stream ones; the provider-specific ones are rig’s own and hidden. - Service
Tier - The processing tier a request asks for.
- Verbosity
- How long the answer should be.
Functions§
- check
- Report each option
targetcannot honour forrequestunder its policy: an error underOnUnsupported::Error; underOnUnsupported::Ignorea warning, and the option is cleared onrequest, so it is reported once. A set option the wire answersMapping::Nothingis an error.Completion::preparecalls it on the routed target before every completion encode. - param
- The value top-level
keygets from the mapped options, the provider options andadditional_params, merged asrequest_paramsmerges them, with no base. For a reader that runs before encoding and must agree with the body. Read only, so it cannot rank anything, and it reports nothing: a refused option adds nothing here. The one sanctioned reader of these layers on the completion path outside the merge. A wire’smap_optionsmust not call it, since it callsmap_options. - request_
params - The body
targetsends forrequest. Reports each refused option (afterCompletion::preparenone is left), then callsbasefor the wire’s own encoding of the request, merges the mapped options, then the provider options at the top level, thenadditional_paramsasraw_atplaces them, and appliesrewritesin order. The only reader of the request’s options, provider options andadditional_paramson the completion path.