创建助手 (v1)Legacy
Legacy
帖子 https://api.openai.com/v1/assistants
创建包含模型和说明的助手。
请求正文
要使用的模型的 ID。您可以使用 List models API 查看所有可用模型,或查看我们的 Model overview 了解它们的描述。type: 字符串
附加到此助手的文件 ID 列表。最多可以有 20 个文件附加到助手。文件按其创建日期升序排序。
使用温度进行采样的替代方法,称为核抽样,其中模型考虑具有top_p概率质量的标记的结果。所以 0.1 意味着只考虑包含前 10% 概率质量的 token。
我们通常建议更改此温度或温度,但不能同时更改两者。
指定模型必须输出的格式。兼容 GPT-4o、GPT-4 Turbo 和所有 GPT-3.5 Turbo 型号gpt-3.5-turbo-1106
.
设置为{ "type": "json_object" }
启用 JSON 模式,该模式保证模型生成的消息是有效的 JSON。
重要提示:使用 JSON 模式时,还必须通过系统或用户消息指示模型自行生成 JSON。否则,模型可能会生成无休止的空格流,直到生成达到令牌限制,从而导致长时间运行且似乎“卡住”的请求。另请注意,如果出现以下情况,消息内容可能会被部分截断finish_reason="length"
,这表示已超过代数max_tokens
或对话超过了最大上下文长度。
返回
辅助对象。
示例请求
1
2
3
4
5
6
7
8
9
10
curl "https://api.openai.com/v1/assistants" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v1" \
-d '{
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
"name": "Math Tutor",
"tools": [{"type": "code_interpreter"}],
"model": "gpt-4-turbo"
}'
响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"id": "asst_abc123",
"object": "assistant",
"created_at": 1698984975,
"name": "Math Tutor",
"description": null,
"model": "gpt-4-turbo",
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
"tools": [
{
"type": "code_interpreter"
}
],
"file_ids": [],
"metadata": {},
"top_p": 1.0,
"temperature": 1.0,
"response_format": "auto"
}