Skip to main content
Assistant API (Deprecated)

Streaming output parameters for the Assistant API (being deprecated)

The Assistant API streaming output provides real-time results from the Assistant. These results are delivered as an event stream, which contains status information and conversation messages from the Assistant's runtime. To process these messages, you must understand message delta objects and run step delta objects.

The Assistant API is being deprecated. Migrate to the Responses API, which offers built-in tools and multi-turn context management.

Message delta object

Event name: thread.message.delta
A message fragment generated by the Large Language Model (LLM) during a streaming run.

Field name

Type

Description

id

string

The message identifier.

object

string

The object type. It is the same as the event name. It is always `thread.message.delta`.

delta

object

The message fragment object generated by the LLM.

delta.role

string

The role that generated the message. The value can be `user` or `assistant`.

delta.file_ids

array

This field is not used.

delta.content

object

The message content object.

delta.content.type

string

The message content type. It is always `text`.

delta.content.text

object

The text content object in the message.

delta.content.text.annotations

array

This field is not used.

delta.content.text.value

string

The text content in the message.

Example of a message delta object
{
    "delta": {
        "content": {
            "text": {
                "annotations": [],
                "value": "[REDACTED]"
            },
            "type": "text"
        },
        "role": "[REDACTED]",
        "file_ids": []
    },
    "id": "[REDACTED]",
    "object": "thread.message.delta",
    "request_id": "[REDACTED]",
    "status_code": 200
}

Run step delta object

Event name: thread.run.step.delta
A message fragment returned by a tool call during a streaming run.

Field Name

Type

Description

id

string

The run step identifier.

object

string

The object type. It is the same as the event name. It is always `thread.run.step.delta`.

delta

object

The message fragment object returned by the tool call.

delta.step_details

object

The detailed step information object for the fragment.

delta.step_details.type

string

The step details type. The value can be `message_creation` or `tool_calls`.

delta.step_details.message_creation

object

The details of the message created in the step.

delta.step_details.message_creation.type

string

It is always `message_creation`.

delta.step_details.message_creation.message_id

string

The ID of the message created in this step.

delta.step_details.tool_calls

array

A list of details for the tool calls.

delta.step_details.tool_calls.type

string

The type of the tool call. The value can be `code_interpreter`, `quark_search`, `text_to_image`, or `calculator`.

delta.step_details.tool_calls.code_interpreter

object

The message object for the code interpreter.

delta.step_details.tool_calls.code_interpreter.arguments

string

The input parameters for the code interpreter. This includes the code type and the complete code. It is generated by the LLM.

delta.step_details.tool_calls.code_interpreter.output

string

The output parameters from the code interpreter. This includes the execution result. It is generated by the code interpreter.

delta.step_details.tool_calls.quark_search

object

The message object for Quark Search.

delta.step_details.tool_calls.quark_search.arguments

string

The input parameters for Quark Search. This includes the rewritten query statement. It is generated by the LLM.

delta.step_details.tool_calls.quark_search.output

string

The output parameters from Quark Search. This includes a success mark, error code, error message, and a list of search results (title, address, description, type, message source). It is generated by Quark Search.

delta.step_details.tool_calls.text_to_image

object

The message object for text-to-image.

delta.step_details.tool_calls.text_to_image.arguments

string

The input parameters for text-to-image. This includes the model name, style, image size, number of images, positive prompt, and negative prompt. It is generated by the LLM.

delta.step_details.tool_calls.text_to_image.output

string

The output parameters from text-to-image. This includes the request ID, task ID, task status, submission time, estimated completion time, end time, generated result, number of images, success mark, and failure mark. It is generated by the text-to-image tool.

delta.step_details.tool_calls.calculator

object

The message object for the calculator.

delta.step_details.tool_calls.calculator.arguments

string

The input parameters for the calculator. This includes the input formula and request header. It is generated by the LLM.

delta.step_details.tool_calls.calculator.output

string

The output parameters from the calculator. This includes the formula and the result. It is generated by the calculator.

The code interpreter, Quark Search, text-to-image, and calculator tools support streaming output.Other Assistant API tools do not support streaming output. To retrieve the results of these tool calls in the streaming output, use the standard tool calling method. For more information, see the relevant section in Tool calling overview.
Example of a run step delta object
{
    "delta": {
        "step_details": {
            "tool_calls": [
                {
                    "code_interpreter": {
                        "output": [],
                        "arguments": "[REDACTED]"
                    },
                    "type": "code_interpreter"
                }
            ],
            "type": "tool_calls"
        }
    },
    "id": "[REDACTED]",
    "object": "thread.run.step.delta",
    "request_id": "[REDACTED]",
    "status_code": 200
}

Assistant event stream

Events that occur when you run an Assistant in streaming mode. In the Assistant API, an event stream consists of an event and data:
  • event: The server sends an event when a new object is created, the state changes, or content is streamed. For example, an event is sent when a new run is created (thread.run.created) or when a run is completed (thread.run.completed).
  • data: Contains detailed data related to the event. For example, it can contain status, text, tool messages, or errors.
event: thread.created
data: {"id": "thread_123", "object": "thread", ...}

Event name

Data type

Description

thread.created

thread

Occurs when a new thread is created.

thread.run.created

run

Occurs when a new run is created.

thread.run.queued

run

Occurs when a run moves to the `queued` state.

thread.run.in_progress

run

Occurs when a run moves to the `in_progress` state.

thread.run.requires_action

run

Occurs when a run moves to the `requires_action` state.

thread.run.completed

run

Occurs when a run is completed.

thread.run.failed

run

Occurs when a run fails.

thread.run.cancelled

run

Occurs when a run is canceled.

thread.run.expired

run

Occurs when a run expires.

thread.run.step.created

run step

Occurs when a run step is created.

thread.run.step.in_progress

run step

Occurs when a run step moves to the `in_progress` state.

thread.run.step.delta

run step delta

Occurs when part of a run step's content is streamed.

thread.run.step.completed

run step

Occurs when a run step is completed.

thread.run.step.failed

run step

Occurs when a run step fails.

thread.run.step.cancelled

run step

Occurs when a run step is canceled.

thread.run.step.expired

run step

Occurs when a run step expires.

thread.message.created

message

Occurs when a message is created.

thread.message.in_progress

message

Occurs when a message enters the `in_progress` state.

thread.message.delta

message delta

Occurs when part of a message's content is streamed.

thread.message.completed

message

Occurs when a message is completed.

thread.message.incomplete

message

Occurs when a message ends before it is completed.

error

error

Triggered when an error occurs. This can be caused by an internal server error or a timeout.

FAQ

  • If you encounter a code execution error when you configure streaming output, see Error messages to troubleshoot the error.
  • To learn how to configure streaming output for the Assistant API, see Quick Start for Assistant API streaming output.