ThreadsBeta
Create threads that assistants can interact with.
Related guide: Assistants
Create threadBeta
Create a thread.
Request body
A list of messages to start the thread with.
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.
Returns
A thread object.
1
2
3
4
5
curl https://api.openai.com/v1/threads \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2" \
-d ''
1
2
3
4
5
6
7
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699012949,
"metadata": {},
"tool_resources": {}
}
Retrieve threadBeta
Retrieves a thread.
Returns
The thread object matching the specified ID.
1
2
3
4
curl https://api.openai.com/v1/threads/thread_abc123 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2"
1
2
3
4
5
6
7
8
9
10
11
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699014083,
"metadata": {},
"tool_resources": {
"code_interpreter": {
"file_ids": []
}
}
}
Modify threadBeta
Modifies a thread.
Path parameters
Request body
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.
Returns
The modified thread object matching the specified ID.
1
2
3
4
5
6
7
8
9
10
curl https://api.openai.com/v1/threads/thread_abc123 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2" \
-d '{
"metadata": {
"modified": "true",
"user": "abc123"
}
}'
1
2
3
4
5
6
7
8
9
10
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699014083,
"metadata": {
"modified": "true",
"user": "abc123"
},
"tool_resources": {}
}
Delete threadBeta
Delete a thread.
Returns
Deletion status
1
2
3
4
5
curl https://api.openai.com/v1/threads/thread_abc123 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2" \
-X DELETE
1
2
3
4
5
{
"id": "thread_abc123",
"object": "thread.deleted",
"deleted": true
}
The thread objectBeta
Represents a thread that contains messages.
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.
1
2
3
4
5
6
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1698107661,
"metadata": {}
}