# Streaming events Server-Sent Events (SSE) streamed when using `stream: true` in the request. ## Event Types **`response.created`** Sent when the response is created and processing begins. details summary Show data structure **`id`** string required The response ID. **`status`** string required Always `in_progress`. Example: ```json {"id":"resp_abc123","status":"in_progress"} ``` **`response.output_item.added`** Sent when a new output item (e.g., message) is added to the response. details summary Show data structure **`index`** integer required The index of the output item. **`item`** object required The output item being added. **`type`** string - The type of item (e.g., `message`) Example: ```json {"index":0,"item":{"type":"message"}} ``` **`response.output_text.delta`** Sent for each text chunk as it's generated. details summary Show data structure **`index`** integer required The index of the output item. **`delta`** string required The text chunk being streamed. Example: ```json {"index":0,"delta":"Hello"} ``` **`response.output_text.done`** Sent when text generation is complete. details summary Show data structure **`text`** string required The complete generated text. Example: ```json {"text":"Hello! How can I help you?"} ``` **`response.completed`** Sent when the entire response is complete. details summary Show data structure **`status`** string required Always `completed`. Example: ```json {"status":"completed"} ``` **`response.failed`** Sent if the response fails. details summary Show data structure **`status`** string required Always `failed`. **`error`** object required Error information. Example: ```json {"status":"failed","error":{"message":"Rate limit exceeded","code":"rate_limit"}} ``` ## Usage These events are streamed by: - [Create a model response](/docs/api-reference/responses/create) - When `stream: true` is set ## Examples Complete Stream ``` event: response.created data: {"id":"resp_abc123","status":"in_progress"} event: response.output_item.added data: {"index":0,"item":{"type":"message"}} event: response.output_text.delta data: {"index":0,"delta":"Hello"} event: response.output_text.delta data: {"index":0,"delta":"! How can I"} event: response.output_text.delta data: {"index":0,"delta":" help you?"} event: response.output_text.done data: {"text":"Hello! How can I help you?"} event: response.completed data: {"status":"completed"} ``` With Error ``` event: response.created data: {"id":"resp_abc123","status":"in_progress"} event: response.output_item.added data: {"index":0,"item":{"type":"message"}} event: response.output_text.delta data: {"index":0,"delta":"I'm proces"} event: response.failed data: {"status":"failed","error":{"message":"Rate limit exceeded","code":"rate_limit_exceeded"}} ``` Parsing in Python ```python import requests response = requests.post( "https://api.freddy.aitronos.com/v1/model/response", headers={"Authorization": f"Bearer {api_key}"}, json={"model": "gpt-4.1", "stream": True, "inputs": [...]}, stream=True ) for line in response.iter_lines(): if line: line_str = line.decode('utf-8') if line_str.startswith('data: '): data = json.loads(line_str[6:]) print(data) ```