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 thefile_search
tool requires a list of vector store IDs. -
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.
POST
/threads
curl \
--request POST 'https://api.openai.com/v1/threads' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"messages":[{"role":"user","content":"string","attachments":[{"file_id":"string","tools":[{"type":"code_interpreter"}]}],"metadata":{"additionalProperty1":"string","additionalProperty2":"string"}}],"tool_resources":{"code_interpreter":{"file_ids":[]},"file_search":{"vector_store_ids":["string"],"vector_stores":[{"file_ids":["string"],"chunking_strategy":{"type":"auto"},"metadata":{"additionalProperty1":"string","additionalProperty2":"string"}}]}},"metadata":{"additionalProperty1":"string","additionalProperty2":"string"}}'
Request examples
{
"messages": [
{
"role": "user",
"content": "string",
"attachments": [
{
"file_id": "string",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"metadata": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}
],
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"string"
],
"vector_stores": [
{
"file_ids": [
"string"
],
"chunking_strategy": {
"type": "auto"
},
"metadata": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}
]
}
},
"metadata": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}
Response examples (200)
{
"id": "string",
"object": "thread",
"created_at": 42,
"tool_resources": {
"code_interpreter": {
"file_ids": []
},
"file_search": {
"vector_store_ids": [
"string"
]
}
},
"metadata": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}