llm-sdk-rs 0.3.0

A Rust library that enables the development of applications that can interact with different language models through a unified interface.
Documentation
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

/// Loosely describe audio format. Some values (e.g., 'wav') denote containers;
/// others (e.g., 'linear16') specify encoding only; cannot describe containers
/// that can contain different audio encodings.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(rename_all = "lowercase")]
pub enum AudioFormat {
    Wav,
    Mp3,
    Linear16,
    Flac,
    Mulaw,
    Alaw,
    Aac,
    Opus,
}

/// A part of the message.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(tag = "type", rename_all = "kebab-case")]
pub enum Part {
    Text(TextPart),
    Image(ImagePart),
    Audio(AudioPart),
    Source(SourcePart),
    ToolCall(ToolCallPart),
    ToolResult(ToolResultPart),
    Reasoning(ReasoningPart),
}

/// Delta parts used in partial updates.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(tag = "type", rename_all = "kebab-case")]
pub enum PartDelta {
    Text(TextPartDelta),
    ToolCall(ToolCallPartDelta),
    Image(ImagePartDelta),
    Audio(AudioPartDelta),
    Reasoning(ReasoningPartDelta),
}

/// A message in an LLM conversation history.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(tag = "role", rename_all = "lowercase")]
pub enum Message {
    User(UserMessage),
    Assistant(AssistantMessage),
    Tool(ToolMessage),
}

/// Defines the modality of content (e.g., text or audio) in LLM responses.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(rename_all = "lowercase")]
pub enum Modality {
    Text,
    Image,
    Audio,
}

/// Determines how the model should choose which tool to use.
/// - "auto" The model will automatically choose the tool to use or not use any
///   tools.
/// - "none" The model will not use any tools.
/// - "required" The model will be forced to use a tool.
/// - { type: "tool", toolName: "toolName" } The model will use the specified
///   tool.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum ToolChoiceOption {
    /// The model will automatically choose the tool to use or not use any
    /// tools.
    Auto,
    /// The model will not use any tools.
    None,
    /// The model will be forced to use a tool.
    Required,
    /// The model will use the specified tool.
    Tool(ToolChoiceTool),
}

/// The format that the model must output.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum ResponseFormatOption {
    /// Specifies that the model response should be in plain text format.
    Text,
    Json(ResponseFormatJson),
}

/// The capabilities supported by the model.
#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct LanguageModelCapabilities {
    pub text_input: bool,
    pub text_output: bool,
    pub image_input: bool,
    pub image_output: bool,
    pub audio_input: bool,
    pub audio_output: bool,
    pub function_calling: bool,
    pub structured_output: bool,
    pub citation: bool,
    pub reasoning: bool,
}

/// A part of the message that contains text.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct TextPart {
    pub text: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub citations: Option<Vec<Citation>>,
}

/// A part of the message that contains an image.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ImagePart {
    /// The MIME type of the image. E.g. "image/jpeg", "image/png".
    pub mime_type: String,
    /// The base64-encoded image data.
    pub data: String,
    /// The width of the image in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u32>,
    /// The height of the image in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<u32>,
    /// The ID of the image part, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// A part of the message that contains an audio.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct AudioPart {
    /// The base64-encoded audio data.
    pub data: String,
    /// The format of the audio.
    pub format: AudioFormat,
    /// The sample rate of the audio. E.g. 44100, 48000.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sample_rate: Option<u32>,
    /// The number of channels of the audio. E.g. 1, 2.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub channels: Option<u32>,
    /// The transcript of the audio.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transcript: Option<String>,
    /// The ID of the audio part, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// A part of the message that contains a source with structured content.
/// It will be used for citation for supported models.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct SourcePart {
    /// The URL or identifier of the document.
    pub source: String,
    /// The title of the document.
    pub title: String,
    /// The content of the document.
    pub content: Vec<Part>,
}

/// A part of the message that represents a call to a tool the model wants to
/// use.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ToolCallPart {
    /// The ID of the tool call, used to match the tool result with the tool
    /// call.
    pub tool_call_id: String,
    /// The name of the tool to call.
    pub tool_name: String,
    /// The arguments to pass to the tool.
    pub args: Value,
    /// The provider-specific signature used to preserve reasoning/tool
    /// continuity.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signature: Option<String>,
    /// The ID of the tool call, if applicable
    /// This is different from `tool_call_id`, which is the ID used to match the
    /// tool result with the tool call.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// A part of the message that represents the result of a tool call.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ToolResultPart {
    /// The ID of the tool call from previous assistant message.
    pub tool_call_id: String,
    /// The name of the tool that was called.
    pub tool_name: String,
    /// The content of the tool result.
    pub content: Vec<Part>,
    /// Marks the tool result as an error.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_error: Option<bool>,
}

// A part of the message that represents the model reasoning.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ReasoningPart {
    /// The reasoning text content.
    pub text: String,
    /// The reasoning internal signature
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signature: Option<String>,
    /// The ID of the reasoning part, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct Citation {
    /**
     * The URL or identifier of the document being cited.
     */
    pub source: String,
    /**
     * The title of the document being cited.
     */
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    /**
     * The text snippet from the document being cited.
     */
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cited_text: Option<String>,
    /**
     * The start index of the document content part being cited.
     */
    pub start_index: usize,
    /**
     * The end index of the document content part being cited.
     */
    pub end_index: usize,
}

/// Represents a message sent by the user.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct UserMessage {
    pub content: Vec<Part>,
}

/// Represents a message generated by the model.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct AssistantMessage {
    pub content: Vec<Part>,
}

/// A delta update for a text part, used in streaming or incremental updates of
/// a message.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct TextPartDelta {
    pub text: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub citation: Option<CitationDelta>,
}

/// A delta update for a citation part, used in streaming of citation messages.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct CitationDelta {
    /// The type of the citation delta.
    #[serde(rename = "type")]
    pub r#type: String,
    /// The URL or identifier of the document being cited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<String>,
    /// The title of the document being cited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    /// The text snippet from the document being cited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cited_text: Option<String>,
    /// The start index of the document content part being cited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_index: Option<usize>,
    /// The end index of the document content part being cited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_index: Option<usize>,
}

/// A delta update for a tool call part, used in streaming of a tool invocation.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ToolCallPartDelta {
    /// The ID of the tool call, used to match the tool result with the tool
    /// call.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// The name of the tool to call.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_name: Option<String>,
    /// The partial JSON string of the arguments to pass to the tool.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<String>,
    /// The provider-specific signature used to preserve reasoning/tool
    /// continuity.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signature: Option<String>,
    /// The ID of the tool call, if applicable
    /// This is different from `tool_call_id`, which is the ID used to match the
    /// tool result with the tool call.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// A delta update for an image part, used in streaming of an image message.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ImagePartDelta {
    /// The MIME type of the image. E.g. "image/jpeg", "image/png".
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// The base64-encoded image data.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<String>,
    /// The width of the image in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u32>,
    /// The height of the image in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<u32>,
    /// The ID of the image part, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// A delta update for an audio part, used in streaming of an audio message.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct AudioPartDelta {
    /// The base64-encoded audio data.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub format: Option<AudioFormat>,
    /// The sample rate of the audio. E.g. 44100, 48000.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sample_rate: Option<u32>,
    /// The number of channels of the audio. E.g. 1, 2.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub channels: Option<u32>,
    /// The transcript of the audio.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transcript: Option<String>,
    /// The ID of the audio part, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

// A delta update for a reasoning part, used in streaming of reasoning messages.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ReasoningPartDelta {
    /// The reasoning text content.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<String>,
    /// The reasoning internal signature
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signature: Option<String>,
    /// The ID of the reasoning part, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// Represents a delta update in a message's content, enabling partial streaming
/// updates in LLM responses.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ContentDelta {
    pub index: usize,
    pub part: PartDelta,
}

/// Represents a JSON schema.
pub type JSONSchema = Value;

/// Represents a tool that can be used by the model.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct Tool {
    /// The name of the tool.
    pub name: String,
    /// A description of the tool.
    pub description: String,
    /// The JSON schema of the parameters that the tool accepts. The type must
    /// be "object".
    pub parameters: JSONSchema,
}

/// Represents tool result in the message history.
/// The only parts of `ToolMessage` should be Part(ToolResultPart).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ToolMessage {
    pub content: Vec<Part>,
}

/// Represents the token usage of the model.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ModelTokensDetails {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text_tokens: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cached_text_tokens: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub audio_tokens: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cached_audio_tokens: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_tokens: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cached_image_tokens: Option<u32>,
}

/// Represents the token usage of the model.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ModelUsage {
    pub input_tokens: u32,
    pub output_tokens: u32,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_tokens_details: Option<ModelTokensDetails>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_tokens_details: Option<ModelTokensDetails>,
}

/// Represents the response generated by the model.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ModelResponse {
    pub content: Vec<Part>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub usage: Option<ModelUsage>,
    /// The cost of the response.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cost: Option<f64>,
}

/// Represents a partial response from the language model, useful for streaming
/// output via async generator.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct PartialModelResponse {
    pub delta: Option<ContentDelta>,
    pub usage: Option<ModelUsage>,
    pub cost: Option<f64>,
}

/// The model will use the specified tool.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ToolChoiceTool {
    pub tool_name: String,
}

/// Specifies that the model response should be in JSON format adhering to a
/// specified schema.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ResponseFormatJson {
    /// The name of the schema.
    pub name: String,
    /// The description of the schema.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schema: Option<JSONSchema>,
}

/// Options for audio generation.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct AudioOptions {
    /// The format of the audio.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub format: Option<AudioFormat>,
    /// The provider-specifc voice ID to use for audio generation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub voice: Option<String>,
    /// The language code for the audio generation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language: Option<String>,
}

/// Options for reasoning generation.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ReasoningOptions {
    /// Whether to enable reasoning output.
    pub enabled: bool,
    /// Specify the budget tokens for reasoning generation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub budget_tokens: Option<u32>,
}

/// Defines the input parameters for the language model completion.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct LanguageModelInput {
    /// A system prompt is a way of providing context and instructions to the
    /// model
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_prompt: Option<String>,
    /// A list of messages comprising the conversation so far.
    pub messages: Vec<Message>,
    /// Definitions of tools that the model may use.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tools: Option<Vec<Tool>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_choice: Option<ToolChoiceOption>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub response_format: Option<ResponseFormatOption>,
    /// The maximum number of tokens that can be generated in the chat
    /// completion.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_tokens: Option<u32>,
    /// Amount of randomness injected into the response. Ranges from 0.0 to 1.0
    #[serde(skip_serializing_if = "Option::is_none")]
    pub temperature: Option<f64>,
    /// An alternative to sampling with temperature, called nucleus sampling,
    /// where the model considers the results of the tokens with `top_p`
    /// probability mass. Ranges from 0.0 to 1.0
    #[serde(skip_serializing_if = "Option::is_none")]
    pub top_p: Option<f64>,
    /// Only sample from the top K options for each subsequent token. Used to
    /// remove 'long tail' low probability responses. Must be a non-negative
    /// integer.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub top_k: Option<i32>,
    /// Positive values penalize new tokens based on whether they appear in the
    /// text so far, increasing the model's likelihood to talk about new topics.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub presence_penalty: Option<f64>,
    /// Positive values penalize new tokens based on their existing frequency in
    /// the text so far, decreasing the model's likelihood to repeat the same
    /// line verbatim.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frequency_penalty: Option<f64>,
    /// The seed (integer), if set and supported by the model, to enable
    /// deterministic results.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seed: Option<i64>,
    /// The modalities that the model should support.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub modalities: Option<Vec<Modality>>,
    /// A set of key/value pairs that store additional information about the
    /// request. This is forwarded to the model provider if supported.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<HashMap<String, String>>,
    /// Options for audio generation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub audio: Option<AudioOptions>,
    /// Options for reasoning generation.
    pub reasoning: Option<ReasoningOptions>,
}

/// A metadata property that describes the pricing of the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct LanguageModelPricing {
    /// The cost in USD per single text token for input.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_cost_per_text_token: Option<f64>,
    /// The cost in USD per single cached text token for input.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_cost_per_cached_text_token: Option<f64>,
    /// The cost in USD per single text token for output.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_cost_per_text_token: Option<f64>,
    /// The cost in USD per single audio token for input.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_cost_per_audio_token: Option<f64>,
    /// The cost in USD per single cached audio token for input.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_cost_per_cached_audio_token: Option<f64>,
    /// The cost in USD per single audio token for output.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_cost_per_audio_token: Option<f64>,
    /// The cost in USD per single image token for input.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_cost_per_image_token: Option<f64>,
    /// The cost in USD per single cached image token for input.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_cost_per_cached_image_token: Option<f64>,
    /// The cost in USD per single image token for output.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_cost_per_image_token: Option<f64>,
}