async_openai/types/responses/
stream.rs

1use futures::Stream;
2use serde::{Deserialize, Serialize};
3use std::pin::Pin;
4
5use crate::{
6    error::OpenAIError,
7    types::responses::{OutputContent, OutputItem, Response, ResponseLogProb, SummaryPart},
8};
9
10/// Stream of response events
11pub type ResponseStream =
12    Pin<Box<dyn Stream<Item = Result<ResponseStreamEvent, OpenAIError>> + Send>>;
13
14/// Event types for streaming responses from the Responses API
15#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
16#[serde(tag = "type")]
17pub enum ResponseStreamEvent {
18    /// An event that is emitted when a response is created.
19    #[serde(rename = "response.created")]
20    ResponseCreated(ResponseCreatedEvent),
21    /// Emitted when the response is in progress.
22    #[serde(rename = "response.in_progress")]
23    ResponseInProgress(ResponseInProgressEvent),
24    /// Emitted when the model response is complete.
25    #[serde(rename = "response.completed")]
26    ResponseCompleted(ResponseCompletedEvent),
27    /// An event that is emitted when a response fails.
28    #[serde(rename = "response.failed")]
29    ResponseFailed(ResponseFailedEvent),
30    /// An event that is emitted when a response finishes as incomplete.
31    #[serde(rename = "response.incomplete")]
32    ResponseIncomplete(ResponseIncompleteEvent),
33    /// Emitted when a new output item is added.
34    #[serde(rename = "response.output_item.added")]
35    ResponseOutputItemAdded(ResponseOutputItemAddedEvent),
36    /// Emitted when an output item is marked done.
37    #[serde(rename = "response.output_item.done")]
38    ResponseOutputItemDone(ResponseOutputItemDoneEvent),
39    /// Emitted when a new content part is added.
40    #[serde(rename = "response.content_part.added")]
41    ResponseContentPartAdded(ResponseContentPartAddedEvent),
42    /// Emitted when a content part is done.
43    #[serde(rename = "response.content_part.done")]
44    ResponseContentPartDone(ResponseContentPartDoneEvent),
45    /// Emitted when there is an additional text delta.
46    #[serde(rename = "response.output_text.delta")]
47    ResponseOutputTextDelta(ResponseTextDeltaEvent),
48    /// Emitted when text content is finalized.
49    #[serde(rename = "response.output_text.done")]
50    ResponseOutputTextDone(ResponseTextDoneEvent),
51    /// Emitted when there is a partial refusal text.
52    #[serde(rename = "response.refusal.delta")]
53    ResponseRefusalDelta(ResponseRefusalDeltaEvent),
54    #[serde(rename = "response.refusal.done")]
55    /// Emitted when refusal text is finalized.
56    ResponseRefusalDone(ResponseRefusalDoneEvent),
57    /// Emitted when there is a partial function-call arguments delta.
58    #[serde(rename = "response.function_call_arguments.delta")]
59    ResponseFunctionCallArgumentsDelta(ResponseFunctionCallArgumentsDeltaEvent),
60    /// Emitted when function-call arguments are finalized.
61    #[serde(rename = "response.function_call_arguments.done")]
62    ResponseFunctionCallArgumentsDone(ResponseFunctionCallArgumentsDoneEvent),
63    /// Emitted when a file search call is initiated.
64    #[serde(rename = "response.file_search_call.in_progress")]
65    ResponseFileSearchCallInProgress(ResponseFileSearchCallInProgressEvent),
66    /// Emitted when a file search is currently searching.
67    #[serde(rename = "response.file_search_call.searching")]
68    ResponseFileSearchCallSearching(ResponseFileSearchCallSearchingEvent),
69    /// Emitted when a file search call is completed (results found).
70    #[serde(rename = "response.file_search_call.completed")]
71    ResponseFileSearchCallCompleted(ResponseFileSearchCallCompletedEvent),
72    /// Emitted when a web search call is initiated.
73    #[serde(rename = "response.web_search_call.in_progress")]
74    ResponseWebSearchCallInProgress(ResponseWebSearchCallInProgressEvent),
75    /// Emitted when a web search call is executing.
76    #[serde(rename = "response.web_search_call.searching")]
77    ResponseWebSearchCallSearching(ResponseWebSearchCallSearchingEvent),
78    /// Emitted when a web search call is completed.
79    #[serde(rename = "response.web_search_call.completed")]
80    ResponseWebSearchCallCompleted(ResponseWebSearchCallCompletedEvent),
81    /// Emitted when a new reasoning summary part is added.
82    #[serde(rename = "response.reasoning_summary_part.added")]
83    ResponseReasoningSummaryPartAdded(ResponseReasoningSummaryPartAddedEvent),
84    /// Emitted when a reasoning summary part is completed.
85    #[serde(rename = "response.reasoning_summary_part.done")]
86    ResponseReasoningSummaryPartDone(ResponseReasoningSummaryPartDoneEvent),
87    /// Emitted when a delta is added to a reasoning summary text.
88    #[serde(rename = "response.reasoning_summary_text.delta")]
89    ResponseReasoningSummaryTextDelta(ResponseReasoningSummaryTextDeltaEvent),
90    /// Emitted when a reasoning summary text is completed.
91    #[serde(rename = "response.reasoning_summary_text.done")]
92    ResponseReasoningSummaryTextDone(ResponseReasoningSummaryTextDoneEvent),
93    /// Emitted when a delta is added to a reasoning text.
94    #[serde(rename = "response.reasoning_text.delta")]
95    ResponseReasoningTextDelta(ResponseReasoningTextDeltaEvent),
96    /// Emitted when a reasoning text is completed.
97    #[serde(rename = "response.reasoning_text.done")]
98    ResponseReasoningTextDone(ResponseReasoningTextDoneEvent),
99    /// Emitted when an image generation tool call has completed and the final image is available.
100    #[serde(rename = "response.image_generation_call.completed")]
101    ResponseImageGenerationCallCompleted(ResponseImageGenCallCompletedEvent),
102    /// Emitted when an image generation tool call is actively generating an image (intermediate state).
103    #[serde(rename = "response.image_generation_call.generating")]
104    ResponseImageGenerationCallGenerating(ResponseImageGenCallGeneratingEvent),
105    /// Emitted when an image generation tool call is in progress.
106    #[serde(rename = "response.image_generation_call.in_progress")]
107    ResponseImageGenerationCallInProgress(ResponseImageGenCallInProgressEvent),
108    /// Emitted when a partial image is available during image generation streaming.
109    #[serde(rename = "response.image_generation_call.partial_image")]
110    ResponseImageGenerationCallPartialImage(ResponseImageGenCallPartialImageEvent),
111    /// Emitted when there is a delta (partial update) to the arguments of an MCP tool call.
112    #[serde(rename = "response.mcp_call_arguments.delta")]
113    ResponseMCPCallArgumentsDelta(ResponseMCPCallArgumentsDeltaEvent),
114    /// Emitted when the arguments for an MCP tool call are finalized.
115    #[serde(rename = "response.mcp_call_arguments.done")]
116    ResponseMCPCallArgumentsDone(ResponseMCPCallArgumentsDoneEvent),
117    /// Emitted when an MCP tool call has completed successfully.
118    #[serde(rename = "response.mcp_call.completed")]
119    ResponseMCPCallCompleted(ResponseMCPCallCompletedEvent),
120    /// Emitted when an MCP tool call has failed.
121    #[serde(rename = "response.mcp_call.failed")]
122    ResponseMCPCallFailed(ResponseMCPCallFailedEvent),
123    /// Emitted when an MCP tool call is in progress.
124    #[serde(rename = "response.mcp_call.in_progress")]
125    ResponseMCPCallInProgress(ResponseMCPCallInProgressEvent),
126    /// Emitted when the list of available MCP tools has been successfully retrieved.
127    #[serde(rename = "response.mcp_list_tools.completed")]
128    ResponseMCPListToolsCompleted(ResponseMCPListToolsCompletedEvent),
129    /// Emitted when the attempt to list available MCP tools has failed.
130    #[serde(rename = "response.mcp_list_tools.failed")]
131    ResponseMCPListToolsFailed(ResponseMCPListToolsFailedEvent),
132    /// Emitted when the system is in the process of retrieving the list of available MCP tools.
133    #[serde(rename = "response.mcp_list_tools.in_progress")]
134    ResponseMCPListToolsInProgress(ResponseMCPListToolsInProgressEvent),
135    /// Emitted when a code interpreter call is in progress.
136    #[serde(rename = "response.code_interpreter_call.in_progress")]
137    ResponseCodeInterpreterCallInProgress(ResponseCodeInterpreterCallInProgressEvent),
138    /// Emitted when the code interpreter is actively interpreting the code snippet.
139    #[serde(rename = "response.code_interpreter_call.interpreting")]
140    ResponseCodeInterpreterCallInterpreting(ResponseCodeInterpreterCallInterpretingEvent),
141    /// Emitted when the code interpreter call is completed.
142    #[serde(rename = "response.code_interpreter_call.completed")]
143    ResponseCodeInterpreterCallCompleted(ResponseCodeInterpreterCallCompletedEvent),
144    /// Emitted when a partial code snippet is streamed by the code interpreter.
145    #[serde(rename = "response.code_interpreter_call_code.delta")]
146    ResponseCodeInterpreterCallCodeDelta(ResponseCodeInterpreterCallCodeDeltaEvent),
147    /// Emitted when the code snippet is finalized by the code interpreter.
148    #[serde(rename = "response.code_interpreter_call_code.done")]
149    ResponseCodeInterpreterCallCodeDone(ResponseCodeInterpreterCallCodeDoneEvent),
150    /// Emitted when an annotation is added to output text content.
151    #[serde(rename = "response.output_text.annotation.added")]
152    ResponseOutputTextAnnotationAdded(ResponseOutputTextAnnotationAddedEvent),
153    /// Emitted when a response is queued and waiting to be processed.
154    #[serde(rename = "response.queued")]
155    ResponseQueued(ResponseQueuedEvent),
156    /// Event representing a delta (partial update) to the input of a custom tool call.
157    #[serde(rename = "response.custom_tool_call_input.delta")]
158    ResponseCustomToolCallInputDelta(ResponseCustomToolCallInputDeltaEvent),
159    /// Event indicating that input for a custom tool call is complete.
160    #[serde(rename = "response.custom_tool_call_input.done")]
161    ResponseCustomToolCallInputDone(ResponseCustomToolCallInputDoneEvent),
162    /// Emitted when an error occurs.
163    #[serde(rename = "error")]
164    ResponseError(ResponseErrorEvent),
165}
166
167#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
168pub struct ResponseCreatedEvent {
169    pub sequence_number: u64,
170    pub response: Response,
171}
172
173#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
174pub struct ResponseInProgressEvent {
175    pub sequence_number: u64,
176    pub response: Response,
177}
178
179#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
180pub struct ResponseCompletedEvent {
181    pub sequence_number: u64,
182    pub response: Response,
183}
184
185#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
186pub struct ResponseFailedEvent {
187    pub sequence_number: u64,
188    pub response: Response,
189}
190
191#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
192pub struct ResponseIncompleteEvent {
193    pub sequence_number: u64,
194    pub response: Response,
195}
196
197#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
198pub struct ResponseOutputItemAddedEvent {
199    pub sequence_number: u64,
200    pub output_index: u32,
201    pub item: OutputItem,
202}
203
204#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
205pub struct ResponseOutputItemDoneEvent {
206    pub sequence_number: u64,
207    pub output_index: u32,
208    pub item: OutputItem,
209}
210
211#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
212pub struct ResponseContentPartAddedEvent {
213    pub sequence_number: u64,
214    pub item_id: String,
215    pub output_index: u32,
216    pub content_index: u32,
217    pub part: OutputContent,
218}
219
220#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
221pub struct ResponseContentPartDoneEvent {
222    pub sequence_number: u64,
223    pub item_id: String,
224    pub output_index: u32,
225    pub content_index: u32,
226    pub part: OutputContent,
227}
228
229#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
230pub struct ResponseTextDeltaEvent {
231    pub sequence_number: u64,
232    pub item_id: String,
233    pub output_index: u32,
234    pub content_index: u32,
235    pub delta: String,
236    #[serde(default, skip_serializing_if = "Option::is_none")]
237    pub logprobs: Option<Vec<ResponseLogProb>>,
238}
239
240#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
241pub struct ResponseTextDoneEvent {
242    pub sequence_number: u64,
243    pub item_id: String,
244    pub output_index: u32,
245    pub content_index: u32,
246    pub text: String,
247    pub logprobs: Option<Vec<ResponseLogProb>>,
248}
249
250#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
251pub struct ResponseRefusalDeltaEvent {
252    pub sequence_number: u64,
253    pub item_id: String,
254    pub output_index: u32,
255    pub content_index: u32,
256    pub delta: String,
257}
258
259#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
260pub struct ResponseRefusalDoneEvent {
261    pub sequence_number: u64,
262    pub item_id: String,
263    pub output_index: u32,
264    pub content_index: u32,
265    pub refusal: String,
266}
267
268#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
269pub struct ResponseFunctionCallArgumentsDeltaEvent {
270    pub sequence_number: u64,
271    pub item_id: String,
272    pub output_index: u32,
273    pub delta: String,
274}
275
276#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
277pub struct ResponseFunctionCallArgumentsDoneEvent {
278    /// https://github.com/64bit/async-openai/issues/472
279    pub name: Option<String>,
280    pub sequence_number: u64,
281    pub item_id: String,
282    pub output_index: u32,
283    pub arguments: String,
284}
285
286#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
287pub struct ResponseFileSearchCallInProgressEvent {
288    pub sequence_number: u64,
289    pub output_index: u32,
290    pub item_id: String,
291}
292
293#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
294pub struct ResponseFileSearchCallSearchingEvent {
295    pub sequence_number: u64,
296    pub output_index: u32,
297    pub item_id: String,
298}
299
300#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
301pub struct ResponseFileSearchCallCompletedEvent {
302    pub sequence_number: u64,
303    pub output_index: u32,
304    pub item_id: String,
305}
306
307#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
308pub struct ResponseWebSearchCallInProgressEvent {
309    pub sequence_number: u64,
310    pub output_index: u32,
311    pub item_id: String,
312}
313
314#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
315pub struct ResponseWebSearchCallSearchingEvent {
316    pub sequence_number: u64,
317    pub output_index: u32,
318    pub item_id: String,
319}
320
321#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
322pub struct ResponseWebSearchCallCompletedEvent {
323    pub sequence_number: u64,
324    pub output_index: u32,
325    pub item_id: String,
326}
327
328#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
329pub struct ResponseReasoningSummaryPartAddedEvent {
330    pub sequence_number: u64,
331    pub item_id: String,
332    pub output_index: u32,
333    pub summary_index: u32,
334    pub part: SummaryPart,
335}
336
337#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
338pub struct ResponseReasoningSummaryPartDoneEvent {
339    pub sequence_number: u64,
340    pub item_id: String,
341    pub output_index: u32,
342    pub summary_index: u32,
343    pub part: SummaryPart,
344}
345
346#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
347pub struct ResponseReasoningSummaryTextDeltaEvent {
348    pub sequence_number: u64,
349    pub item_id: String,
350    pub output_index: u32,
351    pub summary_index: u32,
352    pub delta: String,
353}
354
355#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
356pub struct ResponseReasoningSummaryTextDoneEvent {
357    pub sequence_number: u64,
358    pub item_id: String,
359    pub output_index: u32,
360    pub summary_index: u32,
361    pub text: String,
362}
363
364#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
365pub struct ResponseReasoningTextDeltaEvent {
366    pub sequence_number: u64,
367    pub item_id: String,
368    pub output_index: u32,
369    pub content_index: u32,
370    pub delta: String,
371}
372
373#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
374pub struct ResponseReasoningTextDoneEvent {
375    pub sequence_number: u64,
376    pub item_id: String,
377    pub output_index: u32,
378    pub content_index: u32,
379    pub text: String,
380}
381
382#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
383pub struct ResponseImageGenCallCompletedEvent {
384    pub sequence_number: u64,
385    pub output_index: u32,
386    pub item_id: String,
387}
388
389#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
390pub struct ResponseImageGenCallGeneratingEvent {
391    pub sequence_number: u64,
392    pub output_index: u32,
393    pub item_id: String,
394}
395
396#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
397pub struct ResponseImageGenCallInProgressEvent {
398    pub sequence_number: u64,
399    pub output_index: u32,
400    pub item_id: String,
401}
402
403#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
404pub struct ResponseImageGenCallPartialImageEvent {
405    pub sequence_number: u64,
406    pub output_index: u32,
407    pub item_id: String,
408    pub partial_image_index: u32,
409    pub partial_image_b64: String,
410}
411
412#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
413pub struct ResponseMCPCallArgumentsDeltaEvent {
414    pub sequence_number: u64,
415    pub output_index: u32,
416    pub item_id: String,
417    pub delta: String,
418}
419
420#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
421pub struct ResponseMCPCallArgumentsDoneEvent {
422    pub sequence_number: u64,
423    pub output_index: u32,
424    pub item_id: String,
425    pub arguments: String,
426}
427
428#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
429pub struct ResponseMCPCallCompletedEvent {
430    pub sequence_number: u64,
431    pub output_index: u32,
432    pub item_id: String,
433}
434
435#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
436pub struct ResponseMCPCallFailedEvent {
437    pub sequence_number: u64,
438    pub output_index: u32,
439    pub item_id: String,
440}
441
442#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
443pub struct ResponseMCPCallInProgressEvent {
444    pub sequence_number: u64,
445    pub output_index: u32,
446    pub item_id: String,
447}
448
449#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
450pub struct ResponseMCPListToolsCompletedEvent {
451    pub sequence_number: u64,
452    pub output_index: u32,
453    pub item_id: String,
454}
455
456#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
457pub struct ResponseMCPListToolsFailedEvent {
458    pub sequence_number: u64,
459    pub output_index: u32,
460    pub item_id: String,
461}
462
463#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
464pub struct ResponseMCPListToolsInProgressEvent {
465    pub sequence_number: u64,
466    pub output_index: u32,
467    pub item_id: String,
468}
469
470#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
471pub struct ResponseCodeInterpreterCallInProgressEvent {
472    pub sequence_number: u64,
473    pub output_index: u32,
474    pub item_id: String,
475}
476
477#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
478pub struct ResponseCodeInterpreterCallInterpretingEvent {
479    pub sequence_number: u64,
480    pub output_index: u32,
481    pub item_id: String,
482}
483
484#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
485pub struct ResponseCodeInterpreterCallCompletedEvent {
486    pub sequence_number: u64,
487    pub output_index: u32,
488    pub item_id: String,
489}
490
491#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
492pub struct ResponseCodeInterpreterCallCodeDeltaEvent {
493    pub sequence_number: u64,
494    pub output_index: u32,
495    pub item_id: String,
496    pub delta: String,
497}
498
499#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
500pub struct ResponseCodeInterpreterCallCodeDoneEvent {
501    pub sequence_number: u64,
502    pub output_index: u32,
503    pub item_id: String,
504    pub code: String,
505}
506
507#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
508pub struct ResponseOutputTextAnnotationAddedEvent {
509    pub sequence_number: u64,
510    pub output_index: u32,
511    pub content_index: u32,
512    pub annotation_index: u32,
513    pub item_id: String,
514    pub annotation: serde_json::Value,
515}
516
517#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
518pub struct ResponseQueuedEvent {
519    pub sequence_number: u64,
520    pub response: Response,
521}
522
523#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
524pub struct ResponseCustomToolCallInputDeltaEvent {
525    pub sequence_number: u64,
526    pub output_index: u32,
527    pub item_id: String,
528    pub delta: String,
529}
530
531#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
532pub struct ResponseCustomToolCallInputDoneEvent {
533    pub sequence_number: u64,
534    pub output_index: u32,
535    pub item_id: String,
536    pub input: String,
537}
538
539#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
540pub struct ResponseErrorEvent {
541    pub sequence_number: u64,
542    pub code: Option<String>,
543    pub message: String,
544    pub param: Option<String>,
545}
546
547use crate::traits::EventType;
548
549// Implement EventType trait for all event types in this file
550
551macro_rules! impl_event_type {
552    ($($ty:ty => $event_type:expr),* $(,)?) => {
553        $(
554            impl EventType for $ty {
555                fn event_type(&self) -> &'static str {
556                    $event_type
557                }
558            }
559        )*
560    };
561}
562
563// Apply macro for each event struct type in this file.
564impl_event_type! {
565    ResponseCreatedEvent => "response.created",
566    ResponseInProgressEvent => "response.in_progress",
567    ResponseCompletedEvent => "response.completed",
568    ResponseFailedEvent => "response.failed",
569    ResponseIncompleteEvent => "response.incomplete",
570    ResponseOutputItemAddedEvent => "response.output_item.added",
571    ResponseOutputItemDoneEvent => "response.output_item.done",
572    ResponseContentPartAddedEvent => "response.content_part.added",
573    ResponseContentPartDoneEvent => "response.content_part.done",
574    ResponseTextDeltaEvent => "response.output_text.delta",
575    ResponseTextDoneEvent => "response.output_text.done",
576    ResponseRefusalDeltaEvent => "response.refusal.delta",
577    ResponseRefusalDoneEvent => "response.refusal.done",
578    ResponseFunctionCallArgumentsDeltaEvent => "response.function_call_arguments.delta",
579    ResponseFunctionCallArgumentsDoneEvent => "response.function_call_arguments.done",
580    ResponseFileSearchCallInProgressEvent => "response.file_search_call.in_progress",
581    ResponseFileSearchCallSearchingEvent => "response.file_search_call.searching",
582    ResponseFileSearchCallCompletedEvent => "response.file_search_call.completed",
583    ResponseWebSearchCallInProgressEvent => "response.web_search_call.in_progress",
584    ResponseWebSearchCallSearchingEvent => "response.web_search_call.searching",
585    ResponseWebSearchCallCompletedEvent => "response.web_search_call.completed",
586    ResponseReasoningSummaryPartAddedEvent => "response.reasoning_summary_part.added",
587    ResponseReasoningSummaryPartDoneEvent => "response.reasoning_summary_part.done",
588    ResponseReasoningSummaryTextDeltaEvent => "response.reasoning_summary_text.delta",
589    ResponseReasoningSummaryTextDoneEvent => "response.reasoning_summary_text.done",
590    ResponseReasoningTextDeltaEvent => "response.reasoning_text.delta",
591    ResponseReasoningTextDoneEvent => "response.reasoning_text.done",
592    ResponseImageGenCallCompletedEvent => "response.image_generation_call.completed",
593    ResponseImageGenCallGeneratingEvent => "response.image_generation_call.generating",
594    ResponseImageGenCallInProgressEvent => "response.image_generation_call.in_progress",
595    ResponseImageGenCallPartialImageEvent => "response.image_generation_call.partial_image",
596    ResponseMCPCallArgumentsDeltaEvent => "response.mcp_call_arguments.delta",
597    ResponseMCPCallArgumentsDoneEvent => "response.mcp_call_arguments.done",
598    ResponseMCPCallCompletedEvent => "response.mcp_call.completed",
599    ResponseMCPCallFailedEvent => "response.mcp_call.failed",
600    ResponseMCPCallInProgressEvent => "response.mcp_call.in_progress",
601    ResponseMCPListToolsCompletedEvent => "response.mcp_list_tools.completed",
602    ResponseMCPListToolsFailedEvent => "response.mcp_list_tools.failed",
603    ResponseMCPListToolsInProgressEvent => "response.mcp_list_tools.in_progress",
604    ResponseCodeInterpreterCallInProgressEvent => "response.code_interpreter_call.in_progress",
605    ResponseCodeInterpreterCallInterpretingEvent => "response.code_interpreter_call.interpreting",
606    ResponseCodeInterpreterCallCompletedEvent => "response.code_interpreter_call.completed",
607    ResponseCodeInterpreterCallCodeDeltaEvent => "response.code_interpreter_call_code.delta",
608    ResponseCodeInterpreterCallCodeDoneEvent => "response.code_interpreter_call_code.done",
609    ResponseOutputTextAnnotationAddedEvent => "response.output_text.annotation.added",
610    ResponseQueuedEvent => "response.queued",
611    ResponseCustomToolCallInputDeltaEvent => "response.custom_tool_call_input.delta",
612    ResponseCustomToolCallInputDoneEvent => "response.custom_tool_call_input.done",
613    ResponseErrorEvent => "error",
614}
615
616impl EventType for ResponseStreamEvent {
617    fn event_type(&self) -> &'static str {
618        match self {
619            ResponseStreamEvent::ResponseCreated(event) => event.event_type(),
620            ResponseStreamEvent::ResponseInProgress(event) => event.event_type(),
621            ResponseStreamEvent::ResponseCompleted(event) => event.event_type(),
622            ResponseStreamEvent::ResponseFailed(event) => event.event_type(),
623            ResponseStreamEvent::ResponseIncomplete(event) => event.event_type(),
624            ResponseStreamEvent::ResponseOutputItemAdded(event) => event.event_type(),
625            ResponseStreamEvent::ResponseOutputItemDone(event) => event.event_type(),
626            ResponseStreamEvent::ResponseContentPartAdded(event) => event.event_type(),
627            ResponseStreamEvent::ResponseContentPartDone(event) => event.event_type(),
628            ResponseStreamEvent::ResponseOutputTextDelta(event) => event.event_type(),
629            ResponseStreamEvent::ResponseOutputTextDone(event) => event.event_type(),
630            ResponseStreamEvent::ResponseRefusalDelta(event) => event.event_type(),
631            ResponseStreamEvent::ResponseRefusalDone(event) => event.event_type(),
632            ResponseStreamEvent::ResponseFunctionCallArgumentsDelta(event) => event.event_type(),
633            ResponseStreamEvent::ResponseFunctionCallArgumentsDone(event) => event.event_type(),
634            ResponseStreamEvent::ResponseFileSearchCallInProgress(event) => event.event_type(),
635            ResponseStreamEvent::ResponseFileSearchCallSearching(event) => event.event_type(),
636            ResponseStreamEvent::ResponseFileSearchCallCompleted(event) => event.event_type(),
637            ResponseStreamEvent::ResponseWebSearchCallInProgress(event) => event.event_type(),
638            ResponseStreamEvent::ResponseWebSearchCallSearching(event) => event.event_type(),
639            ResponseStreamEvent::ResponseWebSearchCallCompleted(event) => event.event_type(),
640            ResponseStreamEvent::ResponseReasoningSummaryPartAdded(event) => event.event_type(),
641            ResponseStreamEvent::ResponseReasoningSummaryPartDone(event) => event.event_type(),
642            ResponseStreamEvent::ResponseReasoningSummaryTextDelta(event) => event.event_type(),
643            ResponseStreamEvent::ResponseReasoningSummaryTextDone(event) => event.event_type(),
644            ResponseStreamEvent::ResponseReasoningTextDelta(event) => event.event_type(),
645            ResponseStreamEvent::ResponseReasoningTextDone(event) => event.event_type(),
646            ResponseStreamEvent::ResponseImageGenerationCallCompleted(event) => event.event_type(),
647            ResponseStreamEvent::ResponseImageGenerationCallGenerating(event) => event.event_type(),
648            ResponseStreamEvent::ResponseImageGenerationCallInProgress(event) => event.event_type(),
649            ResponseStreamEvent::ResponseImageGenerationCallPartialImage(event) => {
650                event.event_type()
651            }
652            ResponseStreamEvent::ResponseMCPCallArgumentsDelta(event) => event.event_type(),
653            ResponseStreamEvent::ResponseMCPCallArgumentsDone(event) => event.event_type(),
654            ResponseStreamEvent::ResponseMCPCallCompleted(event) => event.event_type(),
655            ResponseStreamEvent::ResponseMCPCallFailed(event) => event.event_type(),
656            ResponseStreamEvent::ResponseMCPCallInProgress(event) => event.event_type(),
657            ResponseStreamEvent::ResponseMCPListToolsCompleted(event) => event.event_type(),
658            ResponseStreamEvent::ResponseMCPListToolsFailed(event) => event.event_type(),
659            ResponseStreamEvent::ResponseMCPListToolsInProgress(event) => event.event_type(),
660            ResponseStreamEvent::ResponseCodeInterpreterCallInProgress(event) => event.event_type(),
661            ResponseStreamEvent::ResponseCodeInterpreterCallInterpreting(event) => {
662                event.event_type()
663            }
664            ResponseStreamEvent::ResponseCodeInterpreterCallCompleted(event) => event.event_type(),
665            ResponseStreamEvent::ResponseCodeInterpreterCallCodeDelta(event) => event.event_type(),
666            ResponseStreamEvent::ResponseCodeInterpreterCallCodeDone(event) => event.event_type(),
667            ResponseStreamEvent::ResponseOutputTextAnnotationAdded(event) => event.event_type(),
668            ResponseStreamEvent::ResponseQueued(event) => event.event_type(),
669            ResponseStreamEvent::ResponseCustomToolCallInputDelta(event) => event.event_type(),
670            ResponseStreamEvent::ResponseCustomToolCallInputDone(event) => event.event_type(),
671            ResponseStreamEvent::ResponseError(event) => event.event_type(),
672        }
673    }
674}