---
title: "Create a thread."
method: POST
path: "/threads"
tags: ["Assistants"]
---

# Create a thread.

`POST /threads`

## Request body

- CreateThreadRequest
  - `messages` CreateMessageRequest[] — A list of [messages](/docs/api-reference/messages) to start the thread with.
    - `role` 'user' | 'assistant', required — The role of the entity that is creating the message. Allowed values include: - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.
    - `content` union, required
      - string — The text contents of the message.
      - union[] — An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models/overview).
        - union
          - object — References an image [File](/docs/api-reference/files) in the content of a message.
            - `type` 'image_file', required — Always `image_file`.
            - `image_file` object, required
              - …
          - object — References an image URL in the content of a message.
            - `type` 'image_url', required — The type of the content part.
            - `image_url` object, required
              - …
          - object — The text content that is part of a message.
            - `type` 'text', required — Always `text`.
            - `text` string, required — Text content to be sent to the model
    - `attachments` object[], nullable — A list of files attached to the message, and the tools they should be added to.
      - `file_id` string — The ID of the file to attach to the message.
      - `tools` union[] — The tools to add this file to.
        - union
          - object
            - `type` 'code_interpreter', required — The type of tool being defined: `code_interpreter`
          - object
            - `type` 'file_search', required — The type of tool being defined: `file_search`
    - `metadata` object, nullable — 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. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
  - `tool_resources` object, nullable — 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.
    - `code_interpreter` object
      - `file_ids` string[] — 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.
    - `file_search` union
      - object
        - `vector_store_ids` string[], required — 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.
        - `vector_stores` object[] — A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.
          - `file_ids` string[] — A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.
          - `chunking_strategy` union — The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
            - object — The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
              - …
            - object
              - …
          - `metadata` object — Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
      - object
        - `vector_store_ids` string[] — 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.
        - `vector_stores` object[], required — A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.
          - `file_ids` string[] — A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store.
          - `chunking_strategy` union — The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.
            - object — The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
              - …
            - object
              - …
          - `metadata` object — Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
  - `metadata` object, nullable — 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. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

## Response `200`

OK

- ThreadObject — Represents a thread that contains [messages](/docs/api-reference/messages).
  - `id` string, required — The identifier, which can be referenced in API endpoints.
  - `object` 'thread', required — The object type, which is always `thread`.
  - `created_at` integer, required — The Unix timestamp (in seconds) for when the thread was created.
  - `tool_resources` object, nullable, required — 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.
    - `code_interpreter` object
      - `file_ids` string[] — 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.
    - `file_search` object
      - `vector_store_ids` string[] — 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.
  - `metadata` object, nullable, required — 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. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

---

[API](https://skmtc.net/omnistack-sh/apis/openai-api.md) · [All operations](https://skmtc.net/omnistack-sh/apis/openai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/omnistack-sh/openai-api/versions/a127ad1d97cb/schema)
