openai-types 0.1.3

Typed OpenAI API models — zero dependencies beyond serde
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
// AUTO-GENERATED by py2rust — do not edit.
// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
// Domain: conversations

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum ComputerScreenshotContentDetail {
    #[serde(rename = "low")]
    Low,
    #[serde(rename = "high")]
    High,
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "original")]
    Original,
}

/// A screenshot of a computer.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ComputerScreenshotContent {
    /// The detail level of the screenshot image to be sent to the model.
    pub detail: ComputerScreenshotContentDetail,
    /// The identifier of an uploaded file that contains the screenshot.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_id: Option<String>,
    /// The URL of the screenshot image.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub image_url: Option<String>,
    /// Specifies the event type.
    #[serde(rename = "type")]
    pub type_: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct Conversation {
    /// The unique ID of the conversation.
    pub id: String,
    /// The time at which the conversation was created, measured in seconds since the
    pub created_at: i64,
    /// Set of 16 key-value pairs that can be attached to an object.
    pub metadata: serde_json::Value,
    /// The object type, which is always `conversation`.
    pub object: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ConversationCreateParams {
    /// Initial items to include in the conversation context.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub items: Option<Vec<serde_json::Value>>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ConversationDeletedResource {
    pub id: String,
    pub deleted: bool,
    pub object: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum ImageGenerationCallStatus {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "generating")]
    Generating,
    #[serde(rename = "failed")]
    Failed,
}

/// An image generation request made by the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ImageGenerationCall {
    /// The unique ID of the image generation call.
    pub id: String,
    /// The generated image encoded in base64.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub result: Option<String>,
    /// The status of the image generation call.
    pub status: ImageGenerationCallStatus,
    /// The type of the image generation call. Always `image_generation_call`.
    #[serde(rename = "type")]
    pub type_: String,
}

/// Execute a shell command on the server.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct LocalShellCallAction {
    /// The command to run.
    pub command: Vec<String>,
    /// Environment variables to set for the command.
    pub env: std::collections::HashMap<String, String>,
    /// The type of the local shell action. Always `exec`.
    #[serde(rename = "type")]
    pub type_: String,
    /// Optional timeout in milliseconds for the command.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub timeout_ms: Option<i64>,
    /// Optional user to run the command as.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub user: Option<String>,
    /// Optional working directory to run the command in.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub working_directory: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum LocalShellCallStatus {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "incomplete")]
    Incomplete,
}

/// A tool call to run a command on the local shell.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct LocalShellCall {
    /// The unique ID of the local shell call.
    pub id: String,
    /// Execute a shell command on the server.
    pub action: LocalShellCallAction,
    /// The unique ID of the local shell tool call generated by the model.
    pub call_id: String,
    /// The status of the local shell call.
    pub status: LocalShellCallStatus,
    /// The type of the local shell call. Always `local_shell_call`.
    #[serde(rename = "type")]
    pub type_: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum LocalShellCallOutputStatus {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "incomplete")]
    Incomplete,
}

/// The output of a local shell tool call.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct LocalShellCallOutput {
    /// The unique ID of the local shell tool call generated by the model.
    pub id: String,
    /// A JSON string of the output of the local shell tool call.
    pub output: String,
    /// The type of the local shell tool call output. Always `local_shell_call_output`.
    #[serde(rename = "type")]
    pub type_: String,
    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub status: Option<LocalShellCallOutputStatus>,
}

/// A tool available on an MCP server.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct McpListToolsTool {
    /// The JSON schema describing the tool's input.
    pub input_schema: serde_json::Value,
    /// The name of the tool.
    pub name: String,
    /// Additional annotations about the tool.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub annotations: Option<serde_json::Value>,
    /// The description of the tool.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub description: Option<String>,
}

/// A list of tools available on an MCP server.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct McpListTools {
    /// The unique ID of the list.
    pub id: String,
    /// The label of the MCP server.
    pub server_label: String,
    /// The tools available on the server.
    pub tools: Vec<McpListToolsTool>,
    /// The type of the item. Always `mcp_list_tools`.
    #[serde(rename = "type")]
    pub type_: String,
    /// Error message if the server could not list tools.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub error: Option<String>,
}

/// A request for human approval of a tool invocation.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct McpApprovalRequest {
    /// The unique ID of the approval request.
    pub id: String,
    /// A JSON string of arguments for the tool.
    pub arguments: String,
    /// The name of the tool to run.
    pub name: String,
    /// The label of the MCP server making the request.
    pub server_label: String,
    /// The type of the item. Always `mcp_approval_request`.
    #[serde(rename = "type")]
    pub type_: String,
}

/// A response to an MCP approval request.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct McpApprovalResponse {
    /// The unique ID of the approval response
    pub id: String,
    /// The ID of the approval request being answered.
    pub approval_request_id: String,
    /// Whether the request was approved.
    pub approve: bool,
    /// The type of the item. Always `mcp_approval_response`.
    #[serde(rename = "type")]
    pub type_: String,
    /// Optional reason for the decision.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub reason: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum McpCallStatus {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "incomplete")]
    Incomplete,
    #[serde(rename = "calling")]
    Calling,
    #[serde(rename = "failed")]
    Failed,
}

/// An invocation of a tool on an MCP server.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct McpCall {
    /// The unique ID of the tool call.
    pub id: String,
    /// A JSON string of the arguments passed to the tool.
    pub arguments: String,
    /// The name of the tool that was run.
    pub name: String,
    /// The label of the MCP server running the tool.
    pub server_label: String,
    /// The type of the item. Always `mcp_call`.
    #[serde(rename = "type")]
    pub type_: String,
    /// Unique identifier for the MCP tool call approval request. Include this value in
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub approval_request_id: Option<String>,
    /// The error from the tool call, if any.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub error: Option<String>,
    /// The output from the tool call.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub output: Option<String>,
    /// The status of the tool call.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub status: Option<McpCallStatus>,
}

pub type ConversationItem = serde_json::Value;

/// A list of Conversation items.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ConversationItemList {
    /// A list of conversation items.
    pub data: Vec<ConversationItem>,
    /// The ID of the first item in the list.
    pub first_id: String,
    /// Whether there are more items available.
    pub has_more: bool,
    /// The ID of the last item in the list.
    pub last_id: String,
    /// The type of object returned, must be `list`.
    pub object: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ConversationUpdateParams {
    /// Set of 16 key-value pairs that can be attached to an object.
    pub metadata: Option<serde_json::Value>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ItemCreateParams {
    /// The items to add to the conversation. You may add up to 20 items at a time.
    pub items: Vec<serde_json::Value>,
    /// Additional fields to include in the response.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub include: Option<Vec<serde_json::Value>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum ItemListParamsOrder {
    #[serde(rename = "asc")]
    Asc,
    #[serde(rename = "desc")]
    Desc,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ItemListParams {
    /// An item ID to list items after, used in pagination.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub after: Option<String>,
    /// Specify additional output data to include in the model response.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub include: Option<Vec<serde_json::Value>>,
    /// A limit on the number of objects to be returned.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub limit: Option<i64>,
    /// The order to return the input items in. Default is `desc`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub order: Option<ItemListParamsOrder>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ItemRetrieveParams {
    pub conversation_id: String,
    /// Additional fields to include in the response.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub include: Option<Vec<serde_json::Value>>,
}

/// Reasoning text from the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ContentReasoningText {
    /// The reasoning text from the model.
    pub text: String,
    /// The type of the reasoning text. Always `reasoning_text`.
    #[serde(rename = "type")]
    pub type_: String,
}

pub type Content = serde_json::Value;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum MessageRole {
    #[serde(rename = "unknown")]
    Unknown,
    #[serde(rename = "user")]
    User,
    #[serde(rename = "assistant")]
    Assistant,
    #[serde(rename = "system")]
    System,
    #[serde(rename = "critic")]
    Critic,
    #[serde(rename = "discriminator")]
    Discriminator,
    #[serde(rename = "developer")]
    Developer,
    #[serde(rename = "tool")]
    Tool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum MessageStatus {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "incomplete")]
    Incomplete,
}

/// A message to or from the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct Message {
    /// The unique ID of the message.
    pub id: String,
    /// The content of the message
    pub content: Vec<Content>,
    /// The role of the message.
    pub role: MessageRole,
    /// The status of item.
    pub status: MessageStatus,
    /// The type of the message. Always set to `message`.
    #[serde(rename = "type")]
    pub type_: String,
}

/// A summary text from the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct SummaryTextContent {
    /// A summary of the reasoning output from the model so far.
    pub text: String,
    /// The type of the object. Always `summary_text`.
    #[serde(rename = "type")]
    pub type_: String,
}

/// A text content.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct TextContent {
    pub text: String,
    #[serde(rename = "type")]
    pub type_: String,
}