创建消息
POST
https://api.openai.com/v1/threads/{thread_id}/messages
责任人:未设置
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token示例:
Authorization: Bearer ********************
Path 参数
thread_id
string
必需
Body 参数application/json
role
string
必需
content
string
消息的内容。
file_ids
array[string]
可选
metadata
object
可选
示例
{
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.openai.com/v1/threads//messages' \
--header 'Content-Type: application/json' \
--data-raw '{
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}'
返回响应
🟢200成功
application/json
Body
id
string
必需
object
string
必需
thread.message
。created_at
integer
必需
thread_id
string
必需
role
string
必需
user
或之一assistant
。content
array [object {2}]
必需
type
string
可选
text
object
可选
file_ids
array[string]
必需
assistant_id
null
必需
run_id
null
必需
metadata
object
必需
示例
{
"id": "msg_abc123",
"object": "thread.message",
"created_at": 1699017614,
"thread_id": "thread_abc123",
"role": "user",
"content": [
{
"type": "text",
"text": {
"value": "How does AI work? Explain it in simple terms.",
"annotations": []
}
}
],
"file_ids": [],
"assistant_id": null,
"run_id": null,
"metadata": {}
}
修改于 2024-06-28 05:43:44