向会话添加对话项。可以用它提供用户消息、函数调用或函数调用结果,并将其加入对话上下文。服务端通过 conversation.item.created 确认。
conversation.item.create → response.create: 等待匹配的 conversation.item.created,再请求使用新消息生成回答。返回工具结果时也使用相同顺序。
事件字段
事件类型。必须为 conversation.item.create。
新对话项应插入到哪个对话项之后。省略时追加到末尾。使用 root 可插入到对话开头。
message、function_call 或 function_call_output 之一。
completed、incomplete 或 in_progress 之一。通常由服务端返回。
消息变体
item.type: "message" 的消息对话项。
消息 item.role:字符串枚举
与角色互动的用户输入使用 user,之前的角色回答使用 assistant。角色行为通过 Persona 定义。对于 assistant 消息,生成的音频和视频通过 RTC 媒体轨道传输,语音输出文本则通过 response.output_text.* 事件流式返回。
消息 item.content:数组
消息内容片段。系统消息通常使用 input_text;用户消息通常使用 input_text、input_audio 和 input_image;助手消息通常使用 text。
消息 item.content[].type:字符串枚举
input_text、input_audio、input_image 或 text 之一。
消息 item.content[].text:可选字符串
文本内容,与 input_text 和 text 一同使用。
消息 item.content[].audio:可选字符串
Base64 编码的音频,与 input_audio 一同使用。
消息 item.content[].transcript:可选字符串
可选转录文本,与 input_audio 一同使用。
消息 item.content[].image_url:可选字符串
图像 URL,与 input_image 一同使用。
消息 item.content[].detail:可选字符串枚举
图像细节级别:auto、low 或 high,与 input_image 一同使用。
函数调用变体
item.type: "function_call" 的函数调用对话项。
函数调用 item.call_id:可选字符串
函数调用 ID。
函数调用 item.name:字符串
函数名称。
函数调用 item.arguments:字符串
经过 JSON 编码的函数参数。
函数调用输出变体
item.type: "function_call_output" 的函数调用输出对话项。
函数调用输出 item.call_id:字符串
该输出所属的函数调用 ID。
函数调用输出 item.output:字符串
字符串形式的函数输出。