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

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

# AssistantStreamEvent

Represents an event emitted when streaming a Run. Each event in a server-sent events stream has an `event` and `data` property: ``` 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. We may add additional events over time, so we recommend handling unknown events gracefully in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to integrate the Assistants API with streaming.

## OpenAPI definition

````yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
components:
  schemas:
    ThreadStreamEvent:
      oneOf:
        - type: object
          properties:
            enabled:
              type: boolean
              description: Whether to enable input audio transcription.
            event:
              type: string
              enum:
                - thread.created
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/ThreadObject"
          required:
            - event
            - data
          description: Occurs when a new [thread](/docs/api-reference/threads/object) is
            created.
          x-oaiMeta:
            dataDescription: "`data` is a [thread](/docs/api-reference/threads/object)"
    RunStreamEvent:
      oneOf:
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.created
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a new [run](/docs/api-reference/runs/object) is created.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.queued
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) moves to a
            `queued` status.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.in_progress
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) moves to an
            `in_progress` status.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.requires_action
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) moves to a
            `requires_action` status.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.completed
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) is completed.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.incomplete
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) ends with
            status `incomplete`.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.failed
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) fails.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.cancelling
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) moves to a
            `cancelling` status.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.cancelled
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) is cancelled.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.run.expired
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/RunObject"
          required:
            - event
            - data
          description: Occurs when a [run](/docs/api-reference/runs/object) expires.
          x-oaiMeta:
            dataDescription: "`data` is a [run](/docs/api-reference/runs/object)"
    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)"
    MessageStreamEvent:
      oneOf:
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.message.created
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/MessageObject"
          required:
            - event
            - data
          description: Occurs when a [message](/docs/api-reference/messages/object) is
            created.
          x-oaiMeta:
            dataDescription: "`data` is a [message](/docs/api-reference/messages/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.message.in_progress
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/MessageObject"
          required:
            - event
            - data
          description: Occurs when a [message](/docs/api-reference/messages/object) moves
            to an `in_progress` state.
          x-oaiMeta:
            dataDescription: "`data` is a [message](/docs/api-reference/messages/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.message.delta
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/MessageDeltaObject"
          required:
            - event
            - data
          description: Occurs when parts of a
            [Message](/docs/api-reference/messages/object) are being streamed.
          x-oaiMeta:
            dataDescription: "`data` is a [message
              delta](/docs/api-reference/assistants-streaming/message-delta-obj\
              ect)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.message.completed
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/MessageObject"
          required:
            - event
            - data
          description: Occurs when a [message](/docs/api-reference/messages/object) is
            completed.
          x-oaiMeta:
            dataDescription: "`data` is a [message](/docs/api-reference/messages/object)"
        - type: object
          properties:
            event:
              type: string
              enum:
                - thread.message.incomplete
              x-stainless-const: true
            data:
              $ref: "#/components/schemas/MessageObject"
          required:
            - event
            - data
          description: Occurs when a [message](/docs/api-reference/messages/object) ends
            before it is completed.
          x-oaiMeta:
            dataDescription: "`data` is a [message](/docs/api-reference/messages/object)"
    ErrorEvent:
      type: object
      properties:
        event:
          type: string
          enum:
            - error
          x-stainless-const: true
        data:
          $ref: "#/components/schemas/Error"
      required:
        - event
        - data
      description: Occurs when an [error](/docs/guides/error-codes#api-errors) occurs.
        This can happen due to an internal server error or a timeout.
      x-oaiMeta:
        dataDescription: "`data` is an [error](/docs/guides/error-codes#api-errors)"
    DoneEvent:
      type: object
      properties:
        event:
          type: string
          enum:
            - done
          x-stainless-const: true
        data:
          type: string
          enum:
            - "[DONE]"
          x-stainless-const: true
      required:
        - event
        - data
      description: Occurs when a stream ends.
      x-oaiMeta:
        dataDescription: "`data` is `[DONE]`"
    ThreadObject:
      type: object
      title: Thread
      description: Represents a thread that contains
        [messages](/docs/api-reference/messages).
      properties:
        id:
          description: The identifier, which can be referenced in API endpoints.
          type: string
        object:
          description: The object type, which is always `thread`.
          type: string
          enum:
            - thread
          x-stainless-const: true
        created_at:
          description: The Unix timestamp (in seconds) for when the thread was created.
          type: integer
        tool_resources:
          type: object
          description: >
            A set of resources that are made available to the assistant's tools
            in this thread. The resources are specific to the type of tool. For
            example, the `code_interpreter` tool requires a list of file IDs,
            while the `file_search` tool requires a list of vector store IDs.
          properties:
            code_interpreter:
              type: object
              properties:
                file_ids:
                  type: array
                  description: >
                    A list of [file](/docs/api-reference/files) IDs made
                    available to the `code_interpreter` tool. There can be a
                    maximum of 20 files associated with the tool.
                  default: []
                  maxItems: 20
                  items:
                    type: string
            file_search:
              type: object
              properties:
                vector_store_ids:
                  type: array
                  description: >
                    The [vector store](/docs/api-reference/vector-stores/object)
                    attached to this thread. There can be a maximum of 1 vector
                    store attached to the thread.
                  maxItems: 1
                  items:
                    type: string
          nullable: true
        metadata:
          $ref: "#/components/schemas/Metadata"
      required:
        - id
        - object
        - created_at
        - tool_resources
        - metadata
      x-oaiMeta:
        name: The thread object
        beta: true
        example: |
          {
            "id": "thread_abc123",
            "object": "thread",
            "created_at": 1698107661,
            "metadata": {}
          }
    RunObject:
      type: object
      title: A run on a thread
      description: Represents an execution run on a [thread](/docs/api-reference/threads).
      properties:
        id:
          description: The identifier, which can be referenced in API endpoints.
          type: string
        object:
          description: The object type, which is always `thread.run`.
          type: string
          enum:
            - thread.run
          x-stainless-const: true
        created_at:
          description: The Unix timestamp (in seconds) for when the run was created.
          type: integer
        thread_id:
          description: The ID of the [thread](/docs/api-reference/threads) that was
            executed on as a part of this run.
          type: string
        assistant_id:
          description: The ID of the [assistant](/docs/api-reference/assistants) used for
            execution of this run.
          type: string
        status:
          description: The status of the run, which can be either `queued`, `in_progress`,
            `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
            `incomplete`, or `expired`.
          type: string
          enum:
            - queued
            - in_progress
            - requires_action
            - cancelling
            - cancelled
            - failed
            - completed
            - incomplete
            - expired
        required_action:
          type: object
          description: Details on the action required to continue the run. Will be `null`
            if no action is required.
          nullable: true
          properties:
            type:
              description: For now, this is always `submit_tool_outputs`.
              type: string
              enum:
                - submit_tool_outputs
              x-stainless-const: true
            submit_tool_outputs:
              type: object
              description: Details on the tool outputs needed for this run to continue.
              properties:
                tool_calls:
                  type: array
                  description: A list of the relevant tool calls.
                  items:
                    $ref: "#/components/schemas/RunToolCallObject"
              required:
                - tool_calls
          required:
            - type
            - submit_tool_outputs
        last_error:
          type: object
          description: The last error associated with this run. Will be `null` if there
            are no errors.
          nullable: true
          properties:
            code:
              type: string
              description: One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
              enum:
                - server_error
                - rate_limit_exceeded
                - invalid_prompt
            message:
              type: string
              description: A human-readable description of the error.
          required:
            - code
            - message
        expires_at:
          description: The Unix timestamp (in seconds) for when the run will expire.
          type: integer
          nullable: true
        started_at:
          description: The Unix timestamp (in seconds) for when the run was started.
          type: integer
          nullable: true
        cancelled_at:
          description: The Unix timestamp (in seconds) for when the run was cancelled.
          type: integer
          nullable: true
        failed_at:
          description: The Unix timestamp (in seconds) for when the run failed.
          type: integer
          nullable: true
        completed_at:
          description: The Unix timestamp (in seconds) for when the run was completed.
          type: integer
          nullable: true
        incomplete_details:
          description: Details on why the run is incomplete. Will be `null` if the run is
            not incomplete.
          type: object
          nullable: true
          properties:
            reason:
              description: The reason why the run is incomplete. This will point to which
                specific token limit was reached over the course of the run.
              type: string
              enum:
                - max_completion_tokens
                - max_prompt_tokens
        model:
          description: The model that the [assistant](/docs/api-reference/assistants) used
            for this run.
          type: string
        instructions:
          description: The instructions that the
            [assistant](/docs/api-reference/assistants) used for this run.
          type: string
        tools:
          description: The list of tools that the
            [assistant](/docs/api-reference/assistants) used for this run.
          default: []
          type: array
          maxItems: 20
          items:
            oneOf:
              - $ref: "#/components/schemas/AssistantToolsCode"
              - $ref: "#/components/schemas/AssistantToolsFileSearch"
              - $ref: "#/components/schemas/AssistantToolsFunction"
            x-oaiExpandable: true
        metadata:
          $ref: "#/components/schemas/Metadata"
        usage:
          $ref: "#/components/schemas/RunCompletionUsage"
        temperature:
          description: The sampling temperature used for this run. If not set, defaults to
            1.
          type: number
          nullable: true
        top_p:
          description: The nucleus sampling value used for this run. If not set, defaults
            to 1.
          type: number
          nullable: true
        max_prompt_tokens:
          type: integer
          nullable: true
          description: >
            The maximum number of prompt tokens specified to have been used over
            the course of the run.
          minimum: 256
        max_completion_tokens:
          type: integer
          nullable: true
          description: >
            The maximum number of completion tokens specified to have been used
            over the course of the run.
          minimum: 256
        truncation_strategy:
          allOf:
            - $ref: "#/components/schemas/TruncationObject"
            - nullable: true
        tool_choice:
          allOf:
            - $ref: "#/components/schemas/AssistantsApiToolChoiceOption"
            - nullable: true
        parallel_tool_calls:
          $ref: "#/components/schemas/ParallelToolCalls"
        response_format:
          allOf:
            - $ref: "#/components/schemas/AssistantsApiResponseFormatOption"
            - nullable: true
      required:
        - id
        - object
        - created_at
        - thread_id
        - assistant_id
        - status
        - required_action
        - last_error
        - expires_at
        - started_at
        - cancelled_at
        - failed_at
        - completed_at
        - model
        - instructions
        - tools
        - metadata
        - usage
        - incomplete_details
        - max_prompt_tokens
        - max_completion_tokens
        - truncation_strategy
        - tool_choice
        - parallel_tool_calls
        - response_format
      x-oaiMeta:
        name: The run object
        beta: true
        example: |
          {
            "id": "run_abc123",
            "object": "thread.run",
            "created_at": 1698107661,
            "assistant_id": "asst_abc123",
            "thread_id": "thread_abc123",
            "status": "completed",
            "started_at": 1699073476,
            "expires_at": null,
            "cancelled_at": null,
            "failed_at": null,
            "completed_at": 1699073498,
            "last_error": null,
            "model": "gpt-4o",
            "instructions": null,
            "tools": [{"type": "file_search"}, {"type": "code_interpreter"}],
            "metadata": {},
            "incomplete_details": null,
            "usage": {
              "prompt_tokens": 123,
              "completion_tokens": 456,
              "total_tokens": 579
            },
            "temperature": 1.0,
            "top_p": 1.0,
            "max_prompt_tokens": 1000,
            "max_completion_tokens": 1000,
            "truncation_strategy": {
              "type": "auto",
              "last_messages": null
            },
            "response_format": "auto",
            "tool_choice": "auto",
            "parallel_tool_calls": true
          }
    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": [] }
                  }
                ]
              }
            }
          }
    MessageObject:
      type: object
      title: The message object
      description: Represents a message within a [thread](/docs/api-reference/threads).
      properties:
        id:
          description: The identifier, which can be referenced in API endpoints.
          type: string
        object:
          description: The object type, which is always `thread.message`.
          type: string
          enum:
            - thread.message
          x-stainless-const: true
        created_at:
          description: The Unix timestamp (in seconds) for when the message was created.
          type: integer
        thread_id:
          description: The [thread](/docs/api-reference/threads) ID that this message
            belongs to.
          type: string
        status:
          description: The status of the message, which can be either `in_progress`,
            `incomplete`, or `completed`.
          type: string
          enum:
            - in_progress
            - incomplete
            - completed
        incomplete_details:
          description: On an incomplete message, details about why the message is
            incomplete.
          type: object
          properties:
            reason:
              type: string
              description: The reason the message is incomplete.
              enum:
                - content_filter
                - max_tokens
                - run_cancelled
                - run_expired
                - run_failed
          nullable: true
          required:
            - reason
        completed_at:
          description: The Unix timestamp (in seconds) for when the message was completed.
          type: integer
          nullable: true
        incomplete_at:
          description: The Unix timestamp (in seconds) for when the message was marked as
            incomplete.
          type: integer
          nullable: true
        role:
          description: The entity that produced the message. One of `user` or `assistant`.
          type: string
          enum:
            - user
            - assistant
        content:
          description: The content of the message in array of text and/or images.
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/MessageContentImageFileObject"
              - $ref: "#/components/schemas/MessageContentImageUrlObject"
              - $ref: "#/components/schemas/MessageContentTextObject"
              - $ref: "#/components/schemas/MessageContentRefusalObject"
            x-oaiExpandable: true
        assistant_id:
          description: If applicable, the ID of the
            [assistant](/docs/api-reference/assistants) that authored this
            message.
          type: string
          nullable: true
        run_id:
          description: The ID of the [run](/docs/api-reference/runs) associated with the
            creation of this message. Value is `null` when messages are created
            manually using the create message or create thread endpoints.
          type: string
          nullable: true
        attachments:
          type: array
          items:
            type: object
            properties:
              file_id:
                type: string
                description: The ID of the file to attach to the message.
              tools:
                description: The tools to add this file to.
                type: array
                items:
                  oneOf:
                    - $ref: "#/components/schemas/AssistantToolsCode"
                    - $ref: "#/components/schemas/AssistantToolsFileSearchTypeOnly"
                  x-oaiExpandable: true
          description: A list of files attached to the message, and the tools they were
            added to.
          nullable: true
        metadata:
          $ref: "#/components/schemas/Metadata"
      required:
        - id
        - object
        - created_at
        - thread_id
        - status
        - incomplete_details
        - completed_at
        - incomplete_at
        - role
        - content
        - assistant_id
        - run_id
        - attachments
        - metadata
      x-oaiMeta:
        name: The message object
        beta: true
        example: |
          {
            "id": "msg_abc123",
            "object": "thread.message",
            "created_at": 1698983503,
            "thread_id": "thread_abc123",
            "role": "assistant",
            "content": [
              {
                "type": "text",
                "text": {
                  "value": "Hi! How can I help you today?",
                  "annotations": []
                }
              }
            ],
            "assistant_id": "asst_abc123",
            "run_id": "run_abc123",
            "attachments": [],
            "metadata": {}
          }
    MessageDeltaObject:
      type: object
      title: Message delta object
      description: >
        Represents a message delta i.e. any changed fields on a message during
        streaming.
      properties:
        id:
          description: The identifier of the message, which can be referenced in API
            endpoints.
          type: string
        object:
          description: The object type, which is always `thread.message.delta`.
          type: string
          enum:
            - thread.message.delta
          x-stainless-const: true
        delta:
          description: The delta containing the fields that have changed on the Message.
          type: object
          properties:
            role:
              description: The entity that produced the message. One of `user` or `assistant`.
              type: string
              enum:
                - user
                - assistant
            content:
              description: The content of the message in array of text and/or images.
              type: array
              items:
                oneOf:
                  - $ref: "#/components/schemas/MessageDeltaContentImageFileObject"
                  - $ref: "#/components/schemas/MessageDeltaContentTextObject"
                  - $ref: "#/components/schemas/MessageDeltaContentRefusalObject"
                  - $ref: "#/components/schemas/MessageDeltaContentImageUrlObject"
                x-oaiExpandable: true
      required:
        - id
        - object
        - delta
      x-oaiMeta:
        name: The message delta object
        beta: true
        example: |
          {
            "id": "msg_123",
            "object": "thread.message.delta",
            "delta": {
              "content": [
                {
                  "index": 0,
                  "type": "text",
                  "text": { "value": "Hello", "annotations": [] }
                }
              ]
            }
          }
    Error:
      type: object
      properties:
        code:
          type: string
          nullable: true
        message:
          type: string
          nullable: false
        param:
          type: string
          nullable: true
        type:
          type: string
          nullable: false
      required:
        - type
        - message
        - param
        - code
    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
    RunToolCallObject:
      type: object
      description: Tool call objects
      properties:
        id:
          type: string
          description: The ID of the tool call. This ID must be referenced when you submit
            the tool outputs in using the [Submit tool outputs to
            run](/docs/api-reference/runs/submitToolOutputs) endpoint.
        type:
          type: string
          description: The type of tool call the output is required for. For now, this is
            always `function`.
          enum:
            - function
          x-stainless-const: true
        function:
          type: object
          description: The function definition.
          properties:
            name:
              type: string
              description: The name of the function.
            arguments:
              type: string
              description: The arguments that the model expects you to pass to the function.
          required:
            - name
            - arguments
      required:
        - id
        - type
        - function
    AssistantToolsCode:
      type: object
      title: Code interpreter tool
      properties:
        type:
          type: string
          description: "The type of tool being defined: `code_interpreter`"
          enum:
            - code_interpreter
          x-stainless-const: true
      required:
        - type
    AssistantToolsFileSearch:
      type: object
      title: FileSearch tool
      properties:
        type:
          type: string
          description: "The type of tool being defined: `file_search`"
          enum:
            - file_search
          x-stainless-const: true
        file_search:
          type: object
          description: Overrides for the file search tool.
          properties:
            max_num_results:
              type: integer
              minimum: 1
              maximum: 50
              description: |
                The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

                Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.
            ranking_options:
              $ref: "#/components/schemas/FileSearchRankingOptions"
      required:
        - type
    AssistantToolsFunction:
      type: object
      title: Function tool
      properties:
        type:
          type: string
          description: "The type of tool being defined: `function`"
          enum:
            - function
          x-stainless-const: true
        function:
          $ref: "#/components/schemas/FunctionObject"
      required:
        - type
        - function
    RunCompletionUsage:
      type: object
      description: Usage statistics related to the run. This value will be `null` if
        the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).
      properties:
        completion_tokens:
          type: integer
          description: Number of completion tokens used over the course of the run.
        prompt_tokens:
          type: integer
          description: Number of prompt tokens used over the course of the run.
        total_tokens:
          type: integer
          description: Total number of tokens used (prompt + completion).
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      nullable: true
    TruncationObject:
      type: object
      title: Thread Truncation Controls
      description: Controls for how a thread will be truncated prior to the run. Use
        this to control the intial context window of the run.
      properties:
        type:
          type: string
          description: The truncation strategy to use for the thread. The default is
            `auto`. If set to `last_messages`, the thread will be truncated to
            the n most recent messages in the thread. When set to `auto`,
            messages in the middle of the thread will be dropped to fit the
            context length of the model, `max_prompt_tokens`.
          enum:
            - auto
            - last_messages
        last_messages:
          type: integer
          description: The number of most recent messages from the thread when
            constructing the context for the run.
          minimum: 1
          nullable: true
      required:
        - type
    AssistantsApiToolChoiceOption:
      description: >
        Controls which (if any) tool is called by the model.

        `none` means the model will not call any tools and instead generates a
        message.

        `auto` is the default value and means the model can pick between
        generating a message or calling one or more tools.

        `required` means the model must call one or more tools before responding
        to the user.

        Specifying a particular tool like `{"type": "file_search"}` or `{"type":
        "function", "function": {"name": "my_function"}}` forces the model to
        call that tool.
      oneOf:
        - type: string
          description: >
            `none` means the model will not call any tools and instead generates
            a message. `auto` means the model can pick between generating a
            message or calling one or more tools. `required` means the model
            must call one or more tools before responding to the user.
          enum:
            - none
            - auto
            - required
        - $ref: "#/components/schemas/AssistantsNamedToolChoice"
      x-oaiExpandable: true
    ParallelToolCalls:
      description: Whether to enable [parallel function
        calling](/docs/guides/function-calling#configuring-parallel-function-calling)
        during tool use.
      type: boolean
      default: true
    AssistantsApiResponseFormatOption:
      description: >
        Specifies the format that the model must output. Compatible with
        [GPT-4o](/docs/models#gpt-4o), [GPT-4
        Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models
        since `gpt-3.5-turbo-1106`.


        Setting to `{ "type": "json_schema", "json_schema": {...} }` enables
        Structured Outputs which ensures the model will match your supplied JSON
        schema. Learn more in the [Structured Outputs
        guide](/docs/guides/structured-outputs).


        Setting to `{ "type": "json_object" }` enables JSON mode, which ensures
        the message the model generates is valid JSON.


        **Important:** when using JSON mode, you **must** also instruct the
        model to produce JSON yourself via a system or user message. Without
        this, the model may generate an unending stream of whitespace until the
        generation reaches the token limit, resulting in a long-running and
        seemingly "stuck" request. Also note that the message content may be
        partially cut off if `finish_reason="length"`, which indicates the
        generation exceeded `max_tokens` or the conversation exceeded the max
        context length.
      oneOf:
        - type: string
          description: |
            `auto` is the default value
          enum:
            - auto
          x-stainless-const: true
        - $ref: "#/components/schemas/ResponseFormatText"
        - $ref: "#/components/schemas/ResponseFormatJsonObject"
        - $ref: "#/components/schemas/ResponseFormatJsonSchema"
      x-oaiExpandable: true
    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
    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
    MessageContentImageFileObject:
      title: Image file
      type: object
      description: References an image [File](/docs/api-reference/files) in the
        content of a message.
      properties:
        type:
          description: Always `image_file`.
          type: string
          enum:
            - image_file
          x-stainless-const: true
        image_file:
          type: object
          properties:
            file_id:
              description: The [File](/docs/api-reference/files) ID of the image in the
                message content. Set `purpose="vision"` when uploading the File
                if you need to later display the file content.
              type: string
            detail:
              type: string
              description: Specifies the detail level of the image if specified by the user.
                `low` uses fewer tokens, you can opt in to high resolution using
                `high`.
              enum:
                - auto
                - low
                - high
              default: auto
          required:
            - file_id
      required:
        - type
        - image_file
    MessageContentImageUrlObject:
      title: Image URL
      type: object
      description: References an image URL in the content of a message.
      properties:
        type:
          type: string
          enum:
            - image_url
          description: The type of the content part.
          x-stainless-const: true
        image_url:
          type: object
          properties:
            url:
              type: string
              description: "The external URL of the image, must be a supported image types:
                jpeg, jpg, png, gif, webp."
              format: uri
            detail:
              type: string
              description: Specifies the detail level of the image. `low` uses fewer tokens,
                you can opt in to high resolution using `high`. Default value is
                `auto`
              enum:
                - auto
                - low
                - high
              default: auto
          required:
            - url
      required:
        - type
        - image_url
    MessageContentTextObject:
      title: Text
      type: object
      description: The text content that is part of a message.
      properties:
        type:
          description: Always `text`.
          type: string
          enum:
            - text
          x-stainless-const: true
        text:
          type: object
          properties:
            value:
              description: The data that makes up the text.
              type: string
            annotations:
              type: array
              items:
                oneOf:
                  - $ref: "#/components/schemas/MessageContentTextAnnotationsFileCitationObject"
                  - $ref: "#/components/schemas/MessageContentTextAnnotationsFilePathObject"
                x-oaiExpandable: true
          required:
            - value
            - annotations
      required:
        - type
        - text
    MessageContentRefusalObject:
      title: Refusal
      type: object
      description: The refusal content generated by the assistant.
      properties:
        type:
          description: Always `refusal`.
          type: string
          enum:
            - refusal
          x-stainless-const: true
        refusal:
          type: string
          nullable: false
      required:
        - type
        - refusal
    AssistantToolsFileSearchTypeOnly:
      type: object
      title: FileSearch tool
      properties:
        type:
          type: string
          description: "The type of tool being defined: `file_search`"
          enum:
            - file_search
          x-stainless-const: true
      required:
        - type
    MessageDeltaContentImageFileObject:
      title: Image file
      type: object
      description: References an image [File](/docs/api-reference/files) in the
        content of a message.
      properties:
        index:
          type: integer
          description: The index of the content part in the message.
        type:
          description: Always `image_file`.
          type: string
          enum:
            - image_file
          x-stainless-const: true
        image_file:
          type: object
          properties:
            file_id:
              description: The [File](/docs/api-reference/files) ID of the image in the
                message content. Set `purpose="vision"` when uploading the File
                if you need to later display the file content.
              type: string
            detail:
              type: string
              description: Specifies the detail level of the image if specified by the user.
                `low` uses fewer tokens, you can opt in to high resolution using
                `high`.
              enum:
                - auto
                - low
                - high
              default: auto
      required:
        - index
        - type
    MessageDeltaContentTextObject:
      title: Text
      type: object
      description: The text content that is part of a message.
      properties:
        index:
          type: integer
          description: The index of the content part in the message.
        type:
          description: Always `text`.
          type: string
          enum:
            - text
          x-stainless-const: true
        text:
          type: object
          properties:
            value:
              description: The data that makes up the text.
              type: string
            annotations:
              type: array
              items:
                oneOf:
                  - $ref: "#/components/schemas/MessageDeltaContentTextAnnotationsFileCitationObjec\
                      t"
                  - $ref: "#/components/schemas/MessageDeltaContentTextAnnotationsFilePathObject"
                x-oaiExpandable: true
      required:
        - index
        - type
    MessageDeltaContentRefusalObject:
      title: Refusal
      type: object
      description: The refusal content that is part of a message.
      properties:
        index:
          type: integer
          description: The index of the refusal part in the message.
        type:
          description: Always `refusal`.
          type: string
          enum:
            - refusal
          x-stainless-const: true
        refusal:
          type: string
      required:
        - index
        - type
    MessageDeltaContentImageUrlObject:
      title: Image URL
      type: object
      description: References an image URL in the content of a message.
      properties:
        index:
          type: integer
          description: The index of the content part in the message.
        type:
          description: Always `image_url`.
          type: string
          enum:
            - image_url
          x-stainless-const: true
        image_url:
          type: object
          properties:
            url:
              description: "The URL of the image, must be a supported image types: jpeg, jpg,
                png, gif, webp."
              type: string
            detail:
              type: string
              description: Specifies the detail level of the image. `low` uses fewer tokens,
                you can opt in to high resolution using `high`.
              enum:
                - auto
                - low
                - high
              default: auto
      required:
        - index
        - type
    FileSearchRankingOptions:
      title: File search tool call ranking options
      type: object
      description: |
        The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

        See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.
      properties:
        ranker:
          type: string
          description: The ranker to use for the file search. If not specified will use
            the `auto` ranker.
          enum:
            - auto
            - default_2024_08_21
        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:
        - score_threshold
    FunctionObject:
      type: object
      properties:
        description:
          type: string
          description: A description of what the function does, used by the model to
            choose when and how to call the function.
        name:
          type: string
          description: The name of the function to be called. Must be a-z, A-Z, 0-9, or
            contain underscores and dashes, with a maximum length of 64.
        parameters:
          $ref: "#/components/schemas/FunctionParameters"
        strict:
          type: boolean
          nullable: true
          default: false
          description: Whether to enable strict schema adherence when generating the
            function call. If set to true, the model will follow the exact
            schema defined in the `parameters` field. Only a subset of JSON
            Schema is supported when `strict` is `true`. Learn more about
            Structured Outputs in the [function calling
            guide](docs/guides/function-calling).
      required:
        - name
    AssistantsNamedToolChoice:
      type: object
      description: Specifies a tool the model should use. Use to force the model to
        call a specific tool.
      properties:
        type:
          type: string
          enum:
            - function
            - code_interpreter
            - file_search
          description: The type of the tool. If type is `function`, the function name must
            be set
        function:
          type: object
          properties:
            name:
              type: string
              description: The name of the function to call.
          required:
            - name
      required:
        - type
    ResponseFormatText:
      type: object
      properties:
        type:
          type: string
          description: "The type of response format being defined: `text`"
          enum:
            - text
          x-stainless-const: true
      required:
        - type
    ResponseFormatJsonObject:
      type: object
      properties:
        type:
          type: string
          description: "The type of response format being defined: `json_object`"
          enum:
            - json_object
          x-stainless-const: true
      required:
        - type
    ResponseFormatJsonSchema:
      type: object
      properties:
        type:
          type: string
          description: "The type of response format being defined: `json_schema`"
          enum:
            - json_schema
          x-stainless-const: true
        json_schema:
          type: object
          properties:
            description:
              type: string
              description: A description of what the response format is for, used by the model
                to determine how to respond in the format.
            name:
              type: string
              description: The name of the response format. Must be a-z, A-Z, 0-9, or contain
                underscores and dashes, with a maximum length of 64.
            schema:
              $ref: "#/components/schemas/ResponseFormatJsonSchemaSchema"
            strict:
              type: boolean
              nullable: true
              default: false
              description: Whether to enable strict schema adherence when generating the
                output. If set to true, the model will always follow the exact
                schema defined in the `schema` field. Only a subset of JSON
                Schema is supported when `strict` is `true`. To learn more, read
                the [Structured Outputs guide](/docs/guides/structured-outputs).
          required:
            - name
      required:
        - type
        - json_schema
    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
    MessageContentTextAnnotationsFileCitationObject:
      title: File citation
      type: object
      description: A citation within the message that points to a specific quote from
        a specific File associated with the assistant or the message. Generated
        when the assistant uses the "file_search" tool to search files.
      properties:
        type:
          description: Always `file_citation`.
          type: string
          enum:
            - file_citation
          x-stainless-const: true
        text:
          description: The text in the message content that needs to be replaced.
          type: string
        file_citation:
          type: object
          properties:
            file_id:
              description: The ID of the specific File the citation is from.
              type: string
          required:
            - file_id
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      required:
        - type
        - text
        - file_citation
        - start_index
        - end_index
    MessageContentTextAnnotationsFilePathObject:
      title: File path
      type: object
      description: A URL for the file that's generated when the assistant used the
        `code_interpreter` tool to generate a file.
      properties:
        type:
          description: Always `file_path`.
          type: string
          enum:
            - file_path
          x-stainless-const: true
        text:
          description: The text in the message content that needs to be replaced.
          type: string
        file_path:
          type: object
          properties:
            file_id:
              description: The ID of the file that was generated.
              type: string
          required:
            - file_id
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      required:
        - type
        - text
        - file_path
        - start_index
        - end_index
    MessageDeltaContentTextAnnotationsFileCitationObject:
      title: File citation
      type: object
      description: A citation within the message that points to a specific quote from
        a specific File associated with the assistant or the message. Generated
        when the assistant uses the "file_search" tool to search files.
      properties:
        index:
          type: integer
          description: The index of the annotation in the text content part.
        type:
          description: Always `file_citation`.
          type: string
          enum:
            - file_citation
          x-stainless-const: true
        text:
          description: The text in the message content that needs to be replaced.
          type: string
        file_citation:
          type: object
          properties:
            file_id:
              description: The ID of the specific File the citation is from.
              type: string
            quote:
              description: The specific quote in the file.
              type: string
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      required:
        - index
        - type
    MessageDeltaContentTextAnnotationsFilePathObject:
      title: File path
      type: object
      description: A URL for the file that's generated when the assistant used the
        `code_interpreter` tool to generate a file.
      properties:
        index:
          type: integer
          description: The index of the annotation in the text content part.
        type:
          description: Always `file_path`.
          type: string
          enum:
            - file_path
          x-stainless-const: true
        text:
          description: The text in the message content that needs to be replaced.
          type: string
        file_path:
          type: object
          properties:
            file_id:
              description: The ID of the file that was generated.
              type: string
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      required:
        - index
        - type
    FunctionParameters:
      type: object
      description: >-
        The parameters the functions accepts, described as a JSON Schema object.
        See the [guide](/docs/guides/function-calling) for examples, and the
        [JSON Schema
        reference](https://json-schema.org/understanding-json-schema/) for
        documentation about the format. 


        Omitting `parameters` defines a function with an empty parameter list.
      additionalProperties: true
    ResponseFormatJsonSchemaSchema:
      type: object
      description: The schema for the response format, described as a JSON Schema object.
      additionalProperties: true
    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
    AssistantStreamEvent:
      description: >
        Represents an event emitted when streaming a Run.


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


        ```

        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.


        We may add additional events over time, so we recommend handling unknown
        events gracefully

        in your code. See the [Assistants API
        quickstart](/docs/assistants/overview) to learn how to

        integrate the Assistants API with streaming.
      oneOf:
        - $ref: "#/components/schemas/ThreadStreamEvent"
        - $ref: "#/components/schemas/RunStreamEvent"
        - $ref: "#/components/schemas/RunStepStreamEvent"
        - $ref: "#/components/schemas/MessageStreamEvent"
        - $ref: "#/components/schemas/ErrorEvent"
        - $ref: "#/components/schemas/DoneEvent"
      x-oaiMeta:
        name: Assistant stream events
        beta: true
````
