Skip to main content

codex_convert_proxy/convert/streaming/
events.rs

1//! Response stream event types for the Responses API streaming protocol.
2
3use crate::types::response_api::ResponseObject;
4
5use super::state::ResponseRequestContext;
6
7/// SSE event types for Responses API streaming.
8#[derive(Debug, Clone)]
9pub enum ResponseStreamEvent {
10    /// Initial response created event.
11    Created {
12        id: String,
13        model: String,
14        status: String,
15        created_at: i64,
16        request_context: Option<ResponseRequestContext>,
17    },
18    /// Response is in progress.
19    InProgress {
20        id: String,
21        model: String,
22        status: String,
23        created_at: i64,
24        request_context: Option<ResponseRequestContext>,
25    },
26    /// Output item was added.
27    OutputItemAdded {
28        output_index: u32,
29        item_id: String,
30        item_type: String,
31        role: Option<String>,
32        call_id: Option<String>,
33    },
34    /// Content part was added.
35    ContentPartAdded {
36        item_id: String,
37        output_index: u32,
38        content_index: u32,
39    },
40    /// Output text delta (content chunk).
41    OutputTextDelta {
42        item_id: String,
43        output_index: u32,
44        content_index: u32,
45        delta: String,
46    },
47    /// Output text done.
48    OutputTextDone {
49        item_id: String,
50        output_index: u32,
51        content_index: u32,
52        text: String,
53    },
54    /// Content part done.
55    ContentPartDone {
56        item_id: String,
57        output_index: u32,
58        content_index: u32,
59        text: String,
60    },
61    /// Output item done.
62    OutputItemDone {
63        output_index: u32,
64        item_id: String,
65        item_type: String,
66        role: Option<String>,
67        call_id: Option<String>,
68        name: Option<String>,
69        arguments: Option<String>,
70        text: Option<String>,
71        refusal: Option<String>,
72    },
73    /// Reasoning output item added.
74    ReasoningAdded {
75        output_index: u32,
76        item_id: String,
77    },
78    /// Reasoning text delta.
79    ReasoningDelta {
80        item_id: String,
81        output_index: u32,
82        content_index: u32,
83        delta: String,
84    },
85    /// Reasoning text done.
86    ReasoningTextDone {
87        item_id: String,
88        output_index: u32,
89        content_index: u32,
90        text: String,
91    },
92    /// Reasoning summary text delta.
93    ReasoningSummaryTextDelta {
94        item_id: String,
95        output_index: u32,
96        content_index: u32,
97        delta: String,
98    },
99    /// Reasoning summary text done.
100    ReasoningSummaryTextDone {
101        item_id: String,
102        output_index: u32,
103        content_index: u32,
104        text: String,
105    },
106    /// Function call arguments delta.
107    FunctionCallArgumentsDelta {
108        output_index: u32,
109        item_id: String,
110        call_id: Option<String>,
111        delta: String,
112    },
113    /// Function call arguments done.
114    FunctionCallArgumentsDone {
115        output_index: u32,
116        item_id: String,
117        call_id: String,
118        name: String,
119        arguments: String,
120    },
121    /// Response completed with final object.
122    Completed {
123        response: Box<ResponseObject>,
124    },
125    /// Response error event.
126    Error {
127        id: Option<String>,
128        error_type: String,
129        message: String,
130        code: Option<String>,
131    },
132    /// Response failed event.
133    Failed {
134        id: String,
135        model: String,
136        status: String,
137        created_at: i64,
138    },
139    /// Response incomplete event.
140    Incomplete {
141        id: String,
142        model: String,
143        status: String,
144        created_at: i64,
145        reason: Option<String>,
146    },
147    /// Refusal content delta.
148    RefusalDelta {
149        item_id: String,
150        output_index: u32,
151        content_index: u32,
152        delta: String,
153    },
154    /// Refusal content done.
155    RefusalDone {
156        item_id: String,
157        output_index: u32,
158        content_index: u32,
159        refusal: String,
160    },
161}