Skip to main content
POST
/
v1
/
threads
from openai import OpenAI
client = OpenAI()

# Create a thread
thread = client.beta.threads.create(
    messages=[
        {
            "role": "user",
            "content": "Explain quantum computing in simple terms."
        }
    ]
)

print(thread.id)
{
  "id": "thread_abc123",
  "object": "thread",
  "created_at": 1699012949,
  "metadata": {},
  "tool_resources": {}
}
The Assistants API is deprecated in favor of the Responses API.
Create a thread for conversations with an assistant.

Create Thread

Request Body

messages
array
A list of messages to start the thread with.
tool_resources
object
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.
metadata
object
Set of 16 key-value pairs that can be attached to an object.Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

Response

Returns a Thread object.
id
string
The thread identifier.
object
string
The object type, always thread.
created_at
integer
The Unix timestamp (in seconds) for when the thread was created.
metadata
object
Set of 16 key-value pairs attached to the object.

Retrieve Thread

GET https://api.openai.com/v1/threads/{thread_id} Retrieves a thread.

Update Thread

POST https://api.openai.com/v1/threads/{thread_id} Modifies a thread.

Delete Thread

DELETE https://api.openai.com/v1/threads/{thread_id} Delete a thread.
from openai import OpenAI
client = OpenAI()

# Create a thread
thread = client.beta.threads.create(
    messages=[
        {
            "role": "user",
            "content": "Explain quantum computing in simple terms."
        }
    ]
)

print(thread.id)
{
  "id": "thread_abc123",
  "object": "thread",
  "created_at": 1699012949,
  "metadata": {},
  "tool_resources": {}
}

Build docs developers (and LLMs) love