Threads
The Threads API is very useful for creating a chat-like experience with a relatively large message history
API Reference
创建新线程,发起对话或互动。
请求体
messagesstring[]必填
metadataobject可选
响应
200成功
application/json
post
/threadsPOST /threads HTTP/1.1
Host: api.aimlapi.com
Content-Type: application/json
Accept: */*
Content-Length: 35
{
"messages": [
"text"
],
"metadata": {}
}200成功
{
"id": "text",
"created_at": 1,
"metadata": null,
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"text"
]
},
"file_search": {
"vector_store_ids": [
"text"
]
}
}
}通过 ID 检索单个线程,提供对其详细信息和消息的访问。
路径参数
threadIdstring必填
响应
200成功
application/json
get
/threads/{threadId}GET /threads/{threadId} HTTP/1.1
Host: api.aimlapi.com
Accept: */*
200成功
{
"id": "text",
"created_at": 1,
"metadata": null,
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"text"
]
},
"file_search": {
"vector_store_ids": [
"text"
]
}
}
}更新现有线程的信息或上下文。
路径参数
threadIdstring必填
请求体
metadataobject可选
响应
200成功
application/json
post
/threads/{threadId}POST /threads/{threadId} HTTP/1.1
Host: api.aimlapi.com
Content-Type: application/json
Accept: */*
Content-Length: 15
{
"metadata": {}
}200成功
{
"id": "text",
"created_at": 1,
"metadata": null,
"object": "thread",
"tool_resources": {
"code_interpreter": {
"file_ids": [
"text"
]
},
"file_search": {
"vector_store_ids": [
"text"
]
}
}
}Example
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"}]
}
]
}
]
) 最后更新于