Streaming (v1)
Legacy

Stream the result of executing a Run or resuming a Run after submitting tool outputs.source

You can stream events from the Create Thread and Run, Create Run, and Submit Tool Outputs endpoints by passing "stream": true. The response will be a Server-Sent events stream.source

Our Node and Python SDKs provide helpful utilities to make streaming easy. Reference the Assistants API quickstart to learn more.source

The message delta object (v1)
Legacy

Represents a message delta i.e. any changed fields on a message during streaming.source

The identifier of the message, which can be referenced in API endpoints.source

The object type, which is always thread.message.delta.source

The delta containing the fields that have changed on the Message.source

OBJECT The message delta object (v1)
1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "id": "msg_123",
  "object": "thread.message.delta",
  "delta": {
    "content": [
      {
        "index": 0,
        "type": "text",
        "text": { "value": "Hello", "annotations": [] }
      }
    ]
  }
}

The run step delta object (v1)
Legacy

Represents a run step delta i.e. any changed fields on a run step during streaming.source

The identifier of the run step, which can be referenced in API endpoints.source

The object type, which is always thread.run.step.delta.source

The delta containing the fields that have changed on the run step.source

OBJECT The run step delta object (v1)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "id": "step_123",
  "object": "thread.run.step.delta",
  "delta": {
    "step_details": {
      "type": "tool_calls",
      "tool_calls": [
        {
          "index": 0,
          "id": "call_123",
          "type": "code_interpreter",
          "code_interpreter": { "input": "", "outputs": [] }
        }
      ]
    }
  }
}

Assistant stream events (v1)
Legacy

Represents an event emitted when streaming a Run.source

Each event in a server-sent events stream has an event and data property:source

event: thread.created
data: {"id": "thread_123", "object": "thread", ...}

We emit events whenever a new object is created, transitions to a new state, or is being streamed in parts (deltas). For example, we emit thread.run.created when a new run is created, thread.run.completed when a run completes, and so on. When an Assistant chooses to create a message during a run, we emit a thread.message.created event, a thread.message.in_progress event, many thread.message.delta events, and finally a thread.message.completed event.source

We may add additional events over time, so we recommend handling unknown events gracefully in your code. See the Assistants API quickstart to learn how to integrate the Assistants API with streaming.source

Occurs when a new thread is created.source

Occurs when a new run is created.source

Occurs when a run moves to a queued status.source

Occurs when a run moves to an in_progress status.source

Occurs when a run moves to a requires_action status.source

Occurs when a run is completed.source

Occurs when a run fails.source

Occurs when a run moves to a cancelling status.source

Occurs when a run is cancelled.source

Occurs when a run expires.source

Occurs when a run step is created.source

Occurs when a run step moves to an in_progress state.source

Occurs when parts of a run step are being streamed.source

Occurs when a run step is completed.source

Occurs when a run step fails.source

Occurs when a run step is cancelled.source

Occurs when a run step expires.source

Occurs when a message is created.source

Occurs when a message moves to an in_progress state.source

Occurs when parts of a Message are being streamed.source

Occurs when a message is completed.source

Occurs when a message ends before it is completed.source

Occurs when an error occurs. This can happen due to an internal server error or a timeout.source

Occurs when a stream ends.source