1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// Copyright 2026 Thomas Santerre and Moderately AI Inc.
//
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Language model generation configuration.
use EnumSetType;
/// Reasoning effort hint for thinking models.
///
/// Six qualitative levels covering the union of every supported provider's
/// effort vocabulary. Per-model `ReasoningCapability` (see
/// [`crate::capabilities::ReasoningCapability`]) declares which subset a
/// given model accepts; calls with an unsupported effort fail validation
/// before reaching the wire.
///
/// `EnumSetType` auto-derives `Copy + Clone + PartialEq + Eq` plus the
/// bitset bookkeeping the `enumset` crate needs to use the values inside
/// an `EnumSet`. `Debug` and `Hash` are derived separately.
/// Error returned when parsing a `ReasoningEffort` from a string that
/// doesn't match one of the six accepted names.
;
/// Resolved reasoning intent passed to providers via
/// [`LanguageModelConfig::reasoning`].
///
/// Three variants — none, adaptive (qualitative effort), manual (explicit
/// budget). The caller resolves the user-facing "auto" mode against
/// the per-model `ReasoningCapability` before constructing this; providers
/// never see "auto".
///
/// Adaptive on OpenAI / Ollama maps to the `reasoning_effort` string; on
/// Anthropic-family it maps to `thinking: {type: "adaptive", effort: ...}`.
/// Manual is Anthropic-family only — `thinking: {type: "enabled",
/// budget_tokens: N}` natively, and `additionalModelRequestFields.thinking`
/// on Bedrock.
/// Prompt-cache time-to-live for cache breakpoints.
///
/// `FiveMin` is the default ephemeral cache (no special handling on
/// either provider). `OneHour` selects the extended TTL — on Bedrock
/// via `CacheTtl::OneHour`, on Anthropic via `cache_control.ttl = "1h"`
/// behind the `extended-cache-ttl-2025-04-11` beta header. The extended
/// TTL costs ~2× on a cache write but the same ~0.1× on reads, so it
/// wins whenever a byte-stable prefix is reused beyond the 5-minute
/// window. Applies to every breakpoint in the request.
/// Latency tier for the generation call.
///
/// `Optimized` requests AWS Bedrock's latency-optimized ("accelerated")
/// inference — faster decode for a short, region-specific set of models,
/// available only through a cross-region inference profile. Only the
/// Bedrock provider honors this; other providers ignore it. The caller
/// layer gates `Optimized` against the per-model
/// [`ModelCapabilities::latency_optimized_supported`](crate::capabilities::ModelCapabilities::latency_optimized_supported)
/// flag and fails loud before the wire, so a model that can't accept it
/// never reaches Bedrock with the field set.
/// Prompt-caching mode for the generation call.
///
/// `Auto` (default) lets the provider engage caching whenever the model is
/// caching-capable and a `CacheBreakpoint` is present. `Off` suppresses
/// caching entirely — no `cachePoint` / `cache_control` is emitted even
/// when a breakpoint marker is present. Useful for latency-critical calls
/// with tiny prompts where caching adds a round-trip for near-zero benefit.
///
/// There is deliberately no "force" mode: forcing caching past the
/// per-model capability gate is what produces the runtime rejections this
/// mode exists to avoid.
/// Configuration for a language model generation call.
///
/// All fields are optional — callers set only what they need. Use
/// `LanguageModelConfig::default()` for provider defaults.
/// Constrains the output format of a language model response.
///
/// Providers that don't support a given format return
/// [`LanguageModelError::Provider`](crate::LanguageModelError::Provider).
///
/// # Provider support
///
/// | Format | OpenAI | Anthropic | Ollama |
/// |--------|--------|-----------|--------|
/// | `Text` | All models | All models | All models |
/// | `JsonObject` | Most models | Not supported | Supported |
/// | `JsonSchema` | Newer models | Beta (sonnet-4-5+, opus-4-1+) | Supported |