Threads
The Threads API is very useful for creating a chat-like experience with a relatively large message history
API Reference
Example
最后更新于
The Threads API is very useful for creating a chat-like experience with a relatively large message history
最后更新于
DELETE /threads/{threadId} HTTP/1.1
Host: api.aimlapi.com
Accept: */*
{
"id": "text",
"object": "thread.deleted",
"deleted": true
}POST /threads HTTP/1.1
Host: api.aimlapi.com
Content-Type: application/json
Accept: */*
Content-Length: 35
{
"messages": [
"text"
],
"metadata": {}
}{
"id": "text",
"created_at": 1,
"metadata": null,
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"text"
]
},
"file_search": {
"vector_store_ids": [
"text"
]
}
}
}GET /threads/{threadId} HTTP/1.1
Host: api.aimlapi.com
Accept: */*
{
"id": "text",
"created_at": 1,
"metadata": null,
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"text"
]
},
"file_search": {
"vector_store_ids": [
"text"
]
}
}
}POST /threads/{threadId} HTTP/1.1
Host: api.aimlapi.com
Content-Type: application/json
Accept: */*
Content-Length: 15
{
"metadata": {}
}{
"id": "text",
"created_at": 1,
"metadata": null,
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"text"
]
},
"file_search": {
"vector_store_ids": [
"text"
]
}
}
}thread = client.beta.threads.create(
messages=[
{
"role": "user",
"content": "Create 3 data visualizations based on the trends in this file.",
"attachments": [
{
"file_id": file.id,
"tools": [{"type": "code_interpreter"}]
}
]
}
]
)