openai_dive 1.4.3

OpenAI Dive is an unofficial async Rust library that allows you to interact with the OpenAI API.
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
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
#[cfg(feature = "stream")]
use super::items::{LogProbs, ReasoningSummaryPart};
use super::{
    items::{
        CodeInterpreterCall, ComputerToolCall, CustomToolCall, FileSearchToolCall,
        FunctionToolCall, ImageGenerationCall, LocalShellCall, McpApprovalRequest, McpListTools,
        McpToolCall, Reasoning, WebSearchToolCall,
    },
    shared::{
        Annotation, ResponseFormat, ResponseTool, ResponseToolChoice, ResponseUsage,
        TruncationStrategy,
    },
};
use crate::v1::resources::shared::ReasoningEffort;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct ResponseObject {
    /// Unix timestamp (in seconds) of when this Response was created.
    pub created_at: u32,
    /// An error object returned when the model fails to generate a Response.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<ResponseError>,
    /// Unique identifier for this Response.
    pub id: String,
    /// Details about why the response is incomplete.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub incomplete_details: Option<IncompleteDetails>,
    /// Inserts a system (or developer) message as the first item in the model's context.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub instruction: Option<String>,
    /// An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_output_tokens: Option<u32>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<HashMap<String, String>>,
    /// Model ID used to generate the response.
    pub model: String,
    /// The object type of this resource - always set to response.
    pub object: String,
    /// An array of content items generated by the model.
    pub output: Vec<ResponseOutput>,
    /// Whether to allow the model to run tool calls in parallel.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parallel_tool_calls: Option<bool>,
    /// The unique ID of the previous response to the model.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous_response_id: Option<String>,
    /// Configuration options for reasoning models.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning: Option<ResponseReasoning>,
    /// The status of the response generation.
    pub status: ReasoningStatus,
    /// What sampling temperature to use, between 0 and 2.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub temperature: Option<f32>,
    /// Configuration options for a text response from the model.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<ResponseText>,
    /// How the model should select which tool (or tools) to use when generating a response.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_choice: Option<ResponseToolChoice>,
    /// An array of tools the model may call while generating a response.
    pub tools: Vec<ResponseTool>,
    /// An alternative to sampling with temperature.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub top_p: Option<f32>,
    /// An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub top_logprobs: Option<u32>,
    /// The truncation strategy to use for the model response.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub truncation: Option<TruncationStrategy>,
    /// Represents token usage details.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub usage: Option<ResponseUsage>,
    /// A unique identifier representing your end-user.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct ResponseError {
    /// The error code for the response.
    pub code: String,
    /// A human-readable description of the error.
    pub message: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct IncompleteDetails {
    /// The reason why the response is incomplete.
    pub reason: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ResponseOutput {
    Message(OutputMessage),
    #[serde(rename = "function_call")]
    FunctionToolCall(FunctionToolCall),
    #[serde(rename = "file_search_call")]
    FileSearchToolCall(FileSearchToolCall),
    #[serde(rename = "web_search_call")]
    WebSearchToolCall(WebSearchToolCall),
    #[serde(rename = "computer_call")]
    ComputerToolCall(ComputerToolCall),
    Reasoning(Reasoning),
    #[serde(rename = "image_generation_call")]
    ImageGenerationCall(ImageGenerationCall),
    #[serde(rename = "code_interpreter_call")]
    CodeInterpreterCall(CodeInterpreterCall),
    #[serde(rename = "local_shell_call")]
    LocalShellCall(LocalShellCall),
    #[serde(rename = "mcp_call")]
    McpToolCall(McpToolCall),
    #[serde(rename = "mcp_list_tools")]
    McpListTools(McpListTools),
    #[serde(rename = "mcp_approval_request")]
    McpApprovalRequest(McpApprovalRequest),
    #[serde(rename = "custom_tool_call")]
    CustomToolCall(CustomToolCall),
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct OutputMessage {
    pub id: String,
    pub role: Role,
    pub status: MessageStatus,
    pub content: Vec<OutputContent>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct ResponseReasoning {
    /// Constrains effort on reasoning for reasoning models.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub effort: Option<ReasoningEffort>,
    // A summary of the reasoning performed by the model.
    pub summary: Option<ReasoningSummary>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct ResponseText {
    /// An object specifying the format that the model must output.
    pub format: ResponseFormat,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ReasoningSummary {
    Auto,
    Concise,
    Detailed,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ReasoningStatus {
    Completed,
    Failed,
    InProgress,
    Incomplete,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum Role {
    User,
    System,
    Assistant,
    Developer,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum MessageStatus {
    InProgress,
    Completed,
    Incomplete,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(tag = "type")]
pub enum OutputContent {
    #[serde(rename = "output_text")]
    Text {
        text: String,
        annotations: Vec<Annotation>,
    },
    #[serde(rename = "reasoning_text")]
    ReasoningText { text: String },
    #[serde(rename = "refusal")]
    Refusal { refusal: String },
}

#[cfg(feature = "stream")]
/// Streaming events for Response API
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(tag = "type")]
pub enum ResponseStreamEvent {
    // Response lifecycle events
    /// response.created - A new response was created
    #[serde(rename = "response.created")]
    ResponseCreated {
        sequence_number: u32,
        response: ResponseObject,
    },
    /// response.queued - Response is queued and waiting to be processed
    #[serde(rename = "response.queued")]
    ResponseQueued {
        sequence_number: u32,
        response: ResponseObject,
    },
    /// response.in_progress - Response is being generated
    #[serde(rename = "response.in_progress")]
    ResponseInProgress {
        sequence_number: u32,
        response: ResponseObject,
    },
    /// response.completed - Response generation completed
    #[serde(rename = "response.completed")]
    ResponseCompleted {
        sequence_number: u32,
        response: ResponseObject,
    },
    /// response.failed - Response generation failed
    #[serde(rename = "response.failed")]
    ResponseFailed {
        sequence_number: u32,
        response: ResponseObject,
    },
    /// response.incomplete - Response finished as incomplete
    #[serde(rename = "response.incomplete")]
    ResponseIncomplete {
        sequence_number: u32,
        response: ResponseObject,
    },

    // Output item events
    /// response.output_item.added - A new output item was added to the response
    #[serde(rename = "response.output_item.added")]
    ResponseOutputItemAdded {
        sequence_number: u32,
        output_index: usize,
        item: ResponseOutput,
    },
    /// response.output_item.done - An output item was completed
    #[serde(rename = "response.output_item.done")]
    ResponseOutputItemDone {
        sequence_number: u32,
        output_index: usize,
        item: ResponseOutput,
    },

    // Content part events
    /// response.content_part.added - A new content part was added
    #[serde(rename = "response.content_part.added")]
    ResponseContentPartAdded {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        part: OutputContent,
    },
    /// response.content_part.done - A content part is done
    #[serde(rename = "response.content_part.done")]
    ResponseContentPartDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        part: OutputContent,
    },

    // Reasoning parts events
    /// response.reasoning_part.added - A new reasoning part was added
    #[serde(rename = "response.reasoning_part.added")]
    ResponseReasoningPartAdded {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        part: OutputContent,
    },
    /// response.reasoning_part.done - A reasoning part is done
    #[serde(rename = "response.reasoning_part.done")]
    ResponseReasoningPartDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        part: OutputContent,
    },

    // Output text events
    /// response.output_text.delta - A text delta was added to an output item
    #[serde(rename = "response.output_text.delta")]
    ResponseOutputTextDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        delta: String,
        #[serde(skip_serializing_if = "Option::is_none")]
        logprobs: Option<Vec<LogProbs>>,
    },
    /// response.output_text.done - Text content is finalized
    #[serde(rename = "response.output_text.done")]
    ResponseOutputTextDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        text: String,
        #[serde(skip_serializing_if = "Option::is_none")]
        logprobs: Option<Vec<LogProbs>>,
    },
    /// response.output_text.annotation.added - An annotation was added to output text
    #[serde(rename = "response.output_text.annotation.added")]
    ResponseOutputTextAnnotationAdded {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        annotation_index: usize,
        annotation: Annotation,
    },

    // Refusal events
    /// response.refusal.delta - A refusal text delta was added
    #[serde(rename = "response.refusal.delta")]
    ResponseRefusalDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        delta: String,
    },
    /// response.refusal.done - Refusal text is finalized
    #[serde(rename = "response.refusal.done")]
    ResponseRefusalDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        refusal: String,
    },

    // Function call events
    /// response.function_call_arguments.delta - A function call arguments delta was added
    #[serde(rename = "response.function_call_arguments.delta")]
    ResponseFunctionCallArgumentsDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        delta: String,
    },
    /// response.function_call_arguments.done - Function call arguments are finalized
    #[serde(rename = "response.function_call_arguments.done")]
    ResponseFunctionCallArgumentsDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        name: String,
        arguments: String,
    },

    // File search events
    /// response.file_search_call.in_progress - A file search call was initiated
    #[serde(rename = "response.file_search_call.in_progress")]
    ResponseFileSearchCallInProgress {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.file_search_call.searching - A file search is currently searching
    #[serde(rename = "response.file_search_call.searching")]
    ResponseFileSearchCallSearching {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.file_search_call.completed - A file search call completed
    #[serde(rename = "response.file_search_call.completed")]
    ResponseFileSearchCallCompleted {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },

    // Web search events
    /// response.web_search_call.in_progress - A web search call was initiated
    #[serde(rename = "response.web_search_call.in_progress")]
    ResponseWebSearchCallInProgress {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.web_search_call.searching - A web search is executing
    #[serde(rename = "response.web_search_call.searching")]
    ResponseWebSearchCallSearching {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.web_search_call.completed - A web search call completed
    #[serde(rename = "response.web_search_call.completed")]
    ResponseWebSearchCallCompleted {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },

    // Reasoning events
    /// response.reasoning_text.delta - A reasoning text delta was added
    #[serde(rename = "response.reasoning_text.delta")]
    ResponseReasoningTextDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        delta: String,
    },
    /// response.reasoning_text.done - Reasoning text is completed
    #[serde(rename = "response.reasoning_text.done")]
    ResponseReasoningTextDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        content_index: usize,
        text: String,
    },
    /// response.reasoning_summary_part.added - A new reasoning summary part was added
    #[serde(rename = "response.reasoning_summary_part.added")]
    ResponseReasoningSummaryPartAdded {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        summary_index: usize,
        part: ReasoningSummaryPart,
    },
    /// response.reasoning_summary_part.done - A reasoning summary part is completed
    #[serde(rename = "response.reasoning_summary_part.done")]
    ResponseReasoningSummaryPartDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        summary_index: usize,
        part: ReasoningSummaryPart,
    },
    /// response.reasoning_summary_text.delta - A reasoning summary text delta was added
    #[serde(rename = "response.reasoning_summary_text.delta")]
    ResponseReasoningSummaryTextDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        summary_index: usize,
        delta: String,
    },
    /// response.reasoning_summary_text.done - Reasoning summary text is completed
    #[serde(rename = "response.reasoning_summary_text.done")]
    ResponseReasoningSummaryTextDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        summary_index: usize,
        text: String,
    },

    // Image generation events
    /// response.image_generation_call.in_progress - Image generation call is in progress
    #[serde(rename = "response.image_generation_call.in_progress")]
    ResponseImageGenerationCallInProgress {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.image_generation_call.generating - Image generation is actively generating
    #[serde(rename = "response.image_generation_call.generating")]
    ResponseImageGenerationCallGenerating {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.image_generation_call.partial_image - A partial image is available
    #[serde(rename = "response.image_generation_call.partial_image")]
    ResponseImageGenerationCallPartialImage {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        partial_image_index: usize,
        partial_image_b64: String,
    },
    /// response.image_generation_call.completed - Image generation completed
    #[serde(rename = "response.image_generation_call.completed")]
    ResponseImageGenerationCallCompleted {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },

    // MCP (Model Context Protocol) events
    /// response.mcp_call.in_progress - MCP tool call is in progress
    #[serde(rename = "response.mcp_call.in_progress")]
    ResponseMcpCallInProgress {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.mcp_call.completed - MCP tool call completed successfully
    #[serde(rename = "response.mcp_call.completed")]
    ResponseMcpCallCompleted {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.mcp_call.failed - MCP tool call failed
    #[serde(rename = "response.mcp_call.failed")]
    ResponseMcpCallFailed {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.mcp_call_arguments.delta - MCP tool call arguments delta
    #[serde(rename = "response.mcp_call_arguments.delta")]
    ResponseMcpCallArgumentsDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        delta: String,
    },
    /// response.mcp_call_arguments.done - MCP tool call arguments finalized
    #[serde(rename = "response.mcp_call_arguments.done")]
    ResponseMcpCallArgumentsDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        arguments: String,
    },
    /// response.mcp_list_tools.in_progress - MCP list tools is in progress
    #[serde(rename = "response.mcp_list_tools.in_progress")]
    ResponseMcpListToolsInProgress {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.mcp_list_tools.completed - MCP list tools completed
    #[serde(rename = "response.mcp_list_tools.completed")]
    ResponseMcpListToolsCompleted {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.mcp_list_tools.failed - MCP list tools failed
    #[serde(rename = "response.mcp_list_tools.failed")]
    ResponseMcpListToolsFailed {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },

    // Code interpreter events
    /// response.code_interpreter_call.in_progress - Code interpreter call is in progress
    #[serde(rename = "response.code_interpreter_call.in_progress")]
    ResponseCodeInterpreterCallInProgress {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.code_interpreter_call.interpreting - Code interpreter is actively interpreting
    #[serde(rename = "response.code_interpreter_call.interpreting")]
    ResponseCodeInterpreterCallInterpreting {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.code_interpreter_call.completed - Code interpreter call completed
    #[serde(rename = "response.code_interpreter_call.completed")]
    ResponseCodeInterpreterCallCompleted {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
    },
    /// response.code_interpreter_call_code.delta - Code interpreter code delta
    #[serde(rename = "response.code_interpreter_call_code.delta")]
    ResponseCodeInterpreterCallCodeDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        delta: String,
    },
    /// response.code_interpreter_call_code.done - Code interpreter code finalized
    #[serde(rename = "response.code_interpreter_call_code.done")]
    ResponseCodeInterpreterCallCodeDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        code: String,
    },

    // Custom tool call events
    /// response.custom_tool_call_input.delta - Custom tool call input delta
    #[serde(rename = "response.custom_tool_call_input.delta")]
    ResponseCustomToolCallInputDelta {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        delta: String,
    },
    /// response.custom_tool_call_input.done - Custom tool call input finalized
    #[serde(rename = "response.custom_tool_call_input.done")]
    ResponseCustomToolCallInputDone {
        sequence_number: u32,
        item_id: String,
        output_index: usize,
        input: String,
    },

    // Keepalive
    /// keepalive - A heartbeat was sent (it's undocumented, but it exists)
    #[serde(rename = "keepalive")]
    Keepalive { sequence_number: u32 },

    // Error event
    /// error - An error occurred
    #[serde(rename = "error")]
    Error {
        sequence_number: u32,
        code: String,
        message: String,
        #[serde(skip_serializing_if = "Option::is_none")]
        param: Option<String>,
    },
}

#[cfg(feature = "stream")]
impl ResponseStreamEvent {
    /// Get the SSE event name for this event
    pub fn event_name(&self) -> &'static str {
        match self {
            Self::ResponseCreated { .. } => "response.created",
            Self::ResponseQueued { .. } => "response.queued",
            Self::ResponseInProgress { .. } => "response.in_progress",
            Self::ResponseCompleted { .. } => "response.completed",
            Self::ResponseFailed { .. } => "response.failed",
            Self::ResponseIncomplete { .. } => "response.incomplete",
            Self::ResponseOutputItemAdded { .. } => "response.output_item.added",
            Self::ResponseOutputItemDone { .. } => "response.output_item.done",
            Self::ResponseContentPartAdded { .. } => "response.content_part.added",
            Self::ResponseContentPartDone { .. } => "response.content_part.done",
            Self::ResponseReasoningPartAdded { .. } => "response.reasoning_part.added",
            Self::ResponseReasoningPartDone { .. } => "response.reasoning_part.done",
            Self::ResponseOutputTextDelta { .. } => "response.output_text.delta",
            Self::ResponseOutputTextDone { .. } => "response.output_text.done",
            Self::ResponseOutputTextAnnotationAdded { .. } => {
                "response.output_text.annotation.added"
            }
            Self::ResponseRefusalDelta { .. } => "response.refusal.delta",
            Self::ResponseRefusalDone { .. } => "response.refusal.done",
            Self::ResponseFunctionCallArgumentsDelta { .. } => {
                "response.function_call_arguments.delta"
            }
            Self::ResponseFunctionCallArgumentsDone { .. } => {
                "response.function_call_arguments.done"
            }
            Self::ResponseFileSearchCallInProgress { .. } => {
                "response.file_search_call.in_progress"
            }
            Self::ResponseFileSearchCallSearching { .. } => "response.file_search_call.searching",
            Self::ResponseFileSearchCallCompleted { .. } => "response.file_search_call.completed",
            Self::ResponseWebSearchCallInProgress { .. } => "response.web_search_call.in_progress",
            Self::ResponseWebSearchCallSearching { .. } => "response.web_search_call.searching",
            Self::ResponseWebSearchCallCompleted { .. } => "response.web_search_call.completed",
            Self::ResponseReasoningTextDelta { .. } => "response.reasoning_text.delta",
            Self::ResponseReasoningTextDone { .. } => "response.reasoning_text.done",
            Self::ResponseReasoningSummaryPartAdded { .. } => {
                "response.reasoning_summary_part.added"
            }
            Self::ResponseReasoningSummaryPartDone { .. } => "response.reasoning_summary_part.done",
            Self::ResponseReasoningSummaryTextDelta { .. } => {
                "response.reasoning_summary_text.delta"
            }
            Self::ResponseReasoningSummaryTextDone { .. } => "response.reasoning_summary_text.done",
            Self::ResponseImageGenerationCallInProgress { .. } => {
                "response.image_generation_call.in_progress"
            }
            Self::ResponseImageGenerationCallGenerating { .. } => {
                "response.image_generation_call.generating"
            }
            Self::ResponseImageGenerationCallPartialImage { .. } => {
                "response.image_generation_call.partial_image"
            }
            Self::ResponseImageGenerationCallCompleted { .. } => {
                "response.image_generation_call.completed"
            }
            Self::ResponseMcpCallInProgress { .. } => "response.mcp_call.in_progress",
            Self::ResponseMcpCallCompleted { .. } => "response.mcp_call.completed",
            Self::ResponseMcpCallFailed { .. } => "response.mcp_call.failed",
            Self::ResponseMcpCallArgumentsDelta { .. } => "response.mcp_call_arguments.delta",
            Self::ResponseMcpCallArgumentsDone { .. } => "response.mcp_call_arguments.done",
            Self::ResponseMcpListToolsInProgress { .. } => "response.mcp_list_tools.in_progress",
            Self::ResponseMcpListToolsCompleted { .. } => "response.mcp_list_tools.completed",
            Self::ResponseMcpListToolsFailed { .. } => "response.mcp_list_tools.failed",
            Self::ResponseCodeInterpreterCallInProgress { .. } => {
                "response.code_interpreter_call.in_progress"
            }
            Self::ResponseCodeInterpreterCallInterpreting { .. } => {
                "response.code_interpreter_call.interpreting"
            }
            Self::ResponseCodeInterpreterCallCompleted { .. } => {
                "response.code_interpreter_call.completed"
            }
            Self::ResponseCodeInterpreterCallCodeDelta { .. } => {
                "response.code_interpreter_call_code.delta"
            }
            Self::ResponseCodeInterpreterCallCodeDone { .. } => {
                "response.code_interpreter_call_code.done"
            }
            Self::ResponseCustomToolCallInputDelta { .. } => {
                "response.custom_tool_call_input.delta"
            }
            Self::ResponseCustomToolCallInputDone { .. } => "response.custom_tool_call_input.done",
            Self::Keepalive { .. } => "keepalive",
            Self::Error { .. } => "error",
        }
    }
}