---
title: "RunStepStreamEvent"
url: "https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1/schemas/RunStepStreamEvent"
---

> Full API specification: https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1.md

# RunStepStreamEvent

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
components:
  schemas:
    RunStepObject:
      type: object
      title: Run steps
      description: |
        Represents a step in execution of a run.
      properties:
        id:
          description: The identifier of the run step, which can be referenced in API
            endpoints.
          type: string
        object:
          description: The object type, which is always `thread.run.step`.
          type: string
          enum:
            - thread.run.step
          x-stainless-const: true
        created_at:
          description: The Unix timestamp (in seconds) for when the run step was created.
          type: integer
        assistant_id:
          description: The ID of the [assistant](/docs/api-reference/assistants)
            associated with the run step.
          type: string
        thread_id:
          description: The ID of the [thread](/docs/api-reference/threads) that was run.
          type: string
        run_id:
          description: The ID of the [run](/docs/api-reference/runs) that this run step is
            a part of.
          type: string
        type:
          description: The type of run step, which can be either `message_creation` or
            `tool_calls`.
          type: string
          enum:
            - message_creation
            - tool_calls
        status:
          description: The status of the run step, which can be either `in_progress`,
            `cancelled`, `failed`, `completed`, or `expired`.
          type: string
          enum:
            - in_progress
            - cancelled
            - failed
            - completed
            - expired
        step_details:
          type: object
          description: The details of the run step.
          oneOf:
            - $ref: "#/components/schemas/RunStepDetailsMessageCreationObject"
            - $ref: "#/components/schemas/RunStepDetailsToolCallsObject"
          x-oaiExpandable: true
        last_error:
          type: object
          description: The last error associated with this run step. Will be `null` if
            there are no errors.
          nullable: true
          properties:
            code:
              type: string
              description: One of `server_error` or `rate_limit_exceeded`.
              enum:
                - server_error
                - rate_limit_exceeded
            message:
              type: string
              description: A human-readable description of the error.
          required:
            - code
            - message
        expired_at:
          description: The Unix timestamp (in seconds) for when the run step expired. A
            step is considered expired if the parent run is expired.
          type: integer
          nullable: true
        cancelled_at:
          description: The Unix timestamp (in seconds) for when the run step was cancelled.
          type: integer
          nullable: true
        failed_at:
          description: The Unix timestamp (in seconds) for when the run step failed.
          type: integer
          nullable: true
        completed_at:
          description: The Unix timestamp (in seconds) for when the run step completed.
          type: integer
          nullable: true
        metadata:
          $ref: "#/components/schemas/Metadata"
        usage:
          $ref: "#/components/schemas/RunStepCompletionUsage"
      required:
        - id
        - object
        - created_at
        - assistant_id
        - thread_id
        - run_id
        - type
        - status
        - step_details
        - last_error
        - expired_at
        - cancelled_at
        - failed_at
        - completed_at
        - metadata
        - usage
      x-oaiMeta:
        name: The run step object
        beta: true
        example: |
          {
            "id": "step_abc123",
            "object": "thread.run.step",
            "created_at": 1699063291,
            "run_id": "run_abc123",
            "assistant_id": "asst_abc123",
            "thread_id": "thread_abc123",
            "type": "message_creation",
            "status": "completed",
            "cancelled_at": null,
            "completed_at": 1699063291,
            "expired_at": null,
            "failed_at": null,
            "last_error": null,
            "step_details": {
              "type": "message_creation",
              "message_creation": {
                "message_id": "msg_abc123"
              }
            },
            "usage": {
              "prompt_tokens": 123,
              "completion_tokens": 456,
              "total_tokens": 579
            }
          }
    RunStepDeltaObject:
      type: object
      title: Run step delta object
      description: >
        Represents a run step delta i.e. any changed fields on a run step during
        streaming.
      properties:
        id:
          description: The identifier of the run step, which can be referenced in API
            endpoints.
          type: string
        object:
          description: The object type, which is always `thread.run.step.delta`.
          type: string
          enum:
            - thread.run.step.delta
          x-stainless-const: true
        delta:
          description: The delta containing the fields that have changed on the run step.
          type: object
          properties:
            step_details:
              type: object
              description: The details of the run step.
              oneOf:
                - $ref: "#/components/schemas/RunStepDeltaStepDetailsMessageCreationObject"
                - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsObject"
              x-oaiExpandable: true
      required:
        - id
        - object
        - delta
      x-oaiMeta:
        name: The run step delta object
        beta: true
        example: |
          {
            "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": [] }
                  }
                ]
              }
            }
          }
    RunStepDetailsMessageCreationObject:
      title: Message creation
      type: object
      description: Details of the message creation by the run step.
      properties:
        type:
          description: Always `message_creation`.
          type: string
          enum:
            - message_creation
          x-stainless-const: true
        message_creation:
          type: object
          properties:
            message_id:
              type: string
              description: The ID of the message that was created by this run step.
          required:
            - message_id
      required:
        - type
        - message_creation
    RunStepDetailsToolCallsObject:
      title: Tool calls
      type: object
      description: Details of the tool call.
      properties:
        type:
          description: Always `tool_calls`.
          type: string
          enum:
            - tool_calls
          x-stainless-const: true
        tool_calls:
          type: array
          description: >
            An array of tool calls the run step was involved in. These can be
            associated with one of three types of tools: `code_interpreter`,
            `file_search`, or `function`.
          items:
            oneOf:
              - $ref: "#/components/schemas/RunStepDetailsToolCallsCodeObject"
              - $ref: "#/components/schemas/RunStepDetailsToolCallsFileSearchObject"
              - $ref: "#/components/schemas/RunStepDetailsToolCallsFunctionObject"
            x-oaiExpandable: true
      required:
        - type
        - tool_calls
    Metadata:
      type: object
      description: >
        Set of 16 key-value pairs that can be attached to an object. This can be

        useful for storing additional information about the object in a
        structured

        format, and querying for objects via API or the dashboard. 


        Keys are strings with a maximum length of 64 characters. Values are
        strings

        with a maximum length of 512 characters.
      additionalProperties:
        type: string
      x-oaiTypeLabel: map
      nullable: true
    RunStepCompletionUsage:
      type: object
      description: Usage statistics related to the run step. This value will be `null`
        while the run step's status is `in_progress`.
      properties:
        completion_tokens:
          type: integer
          description: Number of completion tokens used over the course of the run step.
        prompt_tokens:
          type: integer
          description: Number of prompt tokens used over the course of the run step.
        total_tokens:
          type: integer
          description: Total number of tokens used (prompt + completion).
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      nullable: true
    RunStepDeltaStepDetailsMessageCreationObject:
      title: Message creation
      type: object
      description: Details of the message creation by the run step.
      properties:
        type:
          description: Always `message_creation`.
          type: string
          enum:
            - message_creation
          x-stainless-const: true
        message_creation:
          type: object
          properties:
            message_id:
              type: string
              description: The ID of the message that was created by this run step.
      required:
        - type
    RunStepDeltaStepDetailsToolCallsObject:
      title: Tool calls
      type: object
      description: Details of the tool call.
      properties:
        type:
          description: Always `tool_calls`.
          type: string
          enum:
            - tool_calls
          x-stainless-const: true
        tool_calls:
          type: array
          description: >
            An array of tool calls the run step was involved in. These can be
            associated with one of three types of tools: `code_interpreter`,
            `file_search`, or `function`.
          items:
            oneOf:
              - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsCodeObject"
              - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFileSearchObject"
              - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFunctionObject"
            x-oaiExpandable: true
      required:
        - type
    RunStepDetailsToolCallsCodeObject:
      title: Code Interpreter tool call
      type: object
      description: Details of the Code Interpreter tool call the run step was involved in.
      properties:
        id:
          type: string
          description: The ID of the tool call.
        type:
          type: string
          description: The type of tool call. This is always going to be
            `code_interpreter` for this type of tool call.
          enum:
            - code_interpreter
          x-stainless-const: true
        code_interpreter:
          type: object
          description: The Code Interpreter tool call definition.
          required:
            - input
            - outputs
          properties:
            input:
              type: string
              description: The input to the Code Interpreter tool call.
            outputs:
              type: array
              description: The outputs from the Code Interpreter tool call. Code Interpreter
                can output one or more items, including text (`logs`) or images
                (`image`). Each of these are represented by a different object
                type.
              items:
                type: object
                oneOf:
                  - $ref: "#/components/schemas/RunStepDetailsToolCallsCodeOutputLogsObject"
                  - $ref: "#/components/schemas/RunStepDetailsToolCallsCodeOutputImageObject"
                x-oaiExpandable: true
      required:
        - id
        - type
        - code_interpreter
    RunStepDetailsToolCallsFileSearchObject:
      title: File search tool call
      type: object
      properties:
        id:
          type: string
          description: The ID of the tool call object.
        type:
          type: string
          description: The type of tool call. This is always going to be `file_search` for
            this type of tool call.
          enum:
            - file_search
          x-stainless-const: true
        file_search:
          type: object
          description: For now, this is always going to be an empty object.
          x-oaiTypeLabel: map
          properties:
            ranking_options:
              $ref: "#/components/schemas/RunStepDetailsToolCallsFileSearchRankingOptionsObje\
                ct"
            results:
              type: array
              description: The results of the file search.
              items:
                $ref: "#/components/schemas/RunStepDetailsToolCallsFileSearchResultObject"
      required:
        - id
        - type
        - file_search
    RunStepDetailsToolCallsFunctionObject:
      type: object
      title: Function tool call
      properties:
        id:
          type: string
          description: The ID of the tool call object.
        type:
          type: string
          description: The type of tool call. This is always going to be `function` for
            this type of tool call.
          enum:
            - function
          x-stainless-const: true
        function:
          type: object
          description: The definition of the function that was called.
          properties:
            name:
              type: string
              description: The name of the function.
            arguments:
              type: string
              description: The arguments passed to the function.
            output:
              type: string
              description: The output of the function. This will be `null` if the outputs have
                not been [submitted](/docs/api-reference/runs/submitToolOutputs)
                yet.
              nullable: true
          required:
            - name
            - arguments
            - output
      required:
        - id
        - type
        - function
    RunStepDeltaStepDetailsToolCallsCodeObject:
      title: Code interpreter tool call
      type: object
      description: Details of the Code Interpreter tool call the run step was involved in.
      properties:
        index:
          type: integer
          description: The index of the tool call in the tool calls array.
        id:
          type: string
          description: The ID of the tool call.
        type:
          type: string
          description: The type of tool call. This is always going to be
            `code_interpreter` for this type of tool call.
          enum:
            - code_interpreter
          x-stainless-const: true
        code_interpreter:
          type: object
          description: The Code Interpreter tool call definition.
          properties:
            input:
              type: string
              description: The input to the Code Interpreter tool call.
            outputs:
              type: array
              description: The outputs from the Code Interpreter tool call. Code Interpreter
                can output one or more items, including text (`logs`) or images
                (`image`). Each of these are represented by a different object
                type.
              items:
                type: object
                oneOf:
                  - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsCodeOutputLogsObjec\
                      t"
                  - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsCodeOutputImageObje\
                      ct"
                x-oaiExpandable: true
      required:
        - index
        - type
    RunStepDeltaStepDetailsToolCallsFileSearchObject:
      title: File search tool call
      type: object
      properties:
        index:
          type: integer
          description: The index of the tool call in the tool calls array.
        id:
          type: string
          description: The ID of the tool call object.
        type:
          type: string
          description: The type of tool call. This is always going to be `file_search` for
            this type of tool call.
          enum:
            - file_search
          x-stainless-const: true
        file_search:
          type: object
          description: For now, this is always going to be an empty object.
          x-oaiTypeLabel: map
      required:
        - index
        - type
        - file_search
    RunStepDeltaStepDetailsToolCallsFunctionObject:
      type: object
      title: Function tool call
      properties:
        index:
          type: integer
          description: The index of the tool call in the tool calls array.
        id:
          type: string
          description: The ID of the tool call object.
        type:
          type: string
          description: The type of tool call. This is always going to be `function` for
            this type of tool call.
          enum:
            - function
          x-stainless-const: true
        function:
          type: object
          description: The definition of the function that was called.
          properties:
            name:
              type: string
              description: The name of the function.
            arguments:
              type: string
              description: The arguments passed to the function.
            output:
              type: string
              description: The output of the function. This will be `null` if the outputs have
                not been [submitted](/docs/api-reference/runs/submitToolOutputs)
                yet.
              nullable: true
      required:
        - index
        - type
    RunStepDetailsToolCallsCodeOutputLogsObject:
      title: Code Interpreter log output
      type: object
      description: Text output from the Code Interpreter tool call as part of a run step.
      properties:
        type:
          description: Always `logs`.
          type: string
          enum:
            - logs
          x-stainless-const: true
        logs:
          type: string
          description: The text output from the Code Interpreter tool call.
      required:
        - type
        - logs
    RunStepDetailsToolCallsCodeOutputImageObject:
      title: Code Interpreter image output
      type: object
      properties:
        type:
          description: Always `image`.
          type: string
          enum:
            - image
          x-stainless-const: true
        image:
          type: object
          properties:
            file_id:
              description: The [file](/docs/api-reference/files) ID of the image.
              type: string
          required:
            - file_id
      required:
        - type
        - image
    RunStepDetailsToolCallsFileSearchRankingOptionsObject:
      title: File search tool call ranking options
      type: object
      description: The ranking options for the file search.
      properties:
        ranker:
          type: string
          description: The ranker used for the file search.
          enum:
            - default_2024_08_21
          x-stainless-const: true
        score_threshold:
          type: number
          description: The score threshold for the file search. All values must be a
            floating point number between 0 and 1.
          minimum: 0
          maximum: 1
      required:
        - ranker
        - score_threshold
    RunStepDetailsToolCallsFileSearchResultObject:
      title: File search tool call result
      type: object
      description: A result instance of the file search.
      x-oaiTypeLabel: map
      properties:
        file_id:
          type: string
          description: The ID of the file that result was found in.
        file_name:
          type: string
          description: The name of the file that result was found in.
        score:
          type: number
          description: The score of the result. All values must be a floating point number
            between 0 and 1.
          minimum: 0
          maximum: 1
        content:
          type: array
          description: The content of the result that was found. The content is only
            included if requested via the include query parameter.
          items:
            type: object
            properties:
              type:
                type: string
                description: The type of the content.
                enum:
                  - text
                x-stainless-const: true
              text:
                type: string
                description: The text content of the file.
      required:
        - file_id
        - file_name
        - score
    RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject:
      title: Code interpreter log output
      type: object
      description: Text output from the Code Interpreter tool call as part of a run step.
      properties:
        index:
          type: integer
          description: The index of the output in the outputs array.
        type:
          description: Always `logs`.
          type: string
          enum:
            - logs
          x-stainless-const: true
        logs:
          type: string
          description: The text output from the Code Interpreter tool call.
      required:
        - index
        - type
    RunStepDeltaStepDetailsToolCallsCodeOutputImageObject:
      title: Code interpreter image output
      type: object
      properties:
        index:
          type: integer
          description: The index of the output in the outputs array.
        type:
          description: Always `image`.
          type: string
          enum:
            - image
          x-stainless-const: true
        image:
          type: object
          properties:
            file_id:
              description: The [file](/docs/api-reference/files) ID of the image.
              type: string
      required:
        - index
        - type
    RunStepStreamEvent:
      oneOf:
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.created
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepObject"
          required:
            - event
            - data
          description: Occurs when a [run step](/docs/api-reference/run-steps/step-object)
            is created.
          x-oaiMeta:
            dataDescription: "`data` is a [run step](/docs/api-reference/run-steps/step-object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.in_progress
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepObject"
          required:
            - event
            - data
          description: Occurs when a [run step](/docs/api-reference/run-steps/step-object)
            moves to an `in_progress` state.
          x-oaiMeta:
            dataDescription: "`data` is a [run step](/docs/api-reference/run-steps/step-object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.delta
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepDeltaObject"
          required:
            - event
            - data
          description: Occurs when parts of a [run
            step](/docs/api-reference/run-steps/step-object) are being streamed.
          x-oaiMeta:
            dataDescription: "`data` is a [run step
              delta](/docs/api-reference/assistants-streaming/run-step-delta-ob\
              ject)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.completed
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepObject"
          required:
            - event
            - data
          description: Occurs when a [run step](/docs/api-reference/run-steps/step-object)
            is completed.
          x-oaiMeta:
            dataDescription: "`data` is a [run step](/docs/api-reference/run-steps/step-object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.failed
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepObject"
          required:
            - event
            - data
          description: Occurs when a [run step](/docs/api-reference/run-steps/step-object)
            fails.
          x-oaiMeta:
            dataDescription: "`data` is a [run step](/docs/api-reference/run-steps/step-object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.cancelled
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepObject"
          required:
            - event
            - data
          description: Occurs when a [run step](/docs/api-reference/run-steps/step-object)
            is cancelled.
          x-oaiMeta:
            dataDescription: "`data` is a [run step](/docs/api-reference/run-steps/step-object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.step.expired
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunStepObject"
          required:
            - event
            - data
          description: Occurs when a [run step](/docs/api-reference/run-steps/step-object)
            expires.
          x-oaiMeta:
            dataDescription: "`data` is a [run step](/docs/api-reference/run-steps/step-object)"
```
