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

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

# MessageStreamEvent

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
components:
  schemas:
    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": [] }
                }
              ]
            }
          }
    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
    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
    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
    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
    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
    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
    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)"
```
