Skip to main content
post/completion-messages
Request example
Response
post/completion-messages

Authorization

Authorizationstringheaderrequired#

每个请求都通过 API Key 认证:Authorization: Bearer {API_KEY}。应用接口使用应用 API Key,知识库接口使用知识库 API Key(快速开始)。

API Key 应保存在服务端,切勿嵌入客户端代码。缺失或无效的 Key 会返回 HTTP 401(unauthorized)。

Body

application/json
filesobject[]#
要附加到请求的文件。本地文件需先通过 上传文件 上传,再将返回的 id 作为 upload_file_id 引用,并设置 transfer_method: local_file。
inputsobjectrequired#
应用输入变量的值,以变量名为键。变量名称和类型可从 获取应用参数 响应中的 user_input_form 字段获取。
querystring#
要处理的文本。旧版字段;较新的应用改为在 inputs 中传递。

Default: ""

response_modeenum<string>#
响应返回模式。streaming(推荐)使用 SSE。blocking 等待完成后返回(长时间处理可能会被中断)。Cloudflare 超时为 100 s。省略时默认为阻塞式返回。
Options:streamingblocking
userstringrequired#
终端用户标识,由你的应用定义,需在应用内唯一。消息和文件仅对携带相同 user 的请求可见。参见 终端用户身份。

Responses

请求成功。内容类型和结构取决于请求中的 response_mode 参数。

  • 如果 response_mode 为 blocking,返回 application/json 和 CompletionResponse 对象。
  • 如果 response_mode 为 streaming,返回 text/event-stream 和 ChunkCompletionEvent 对象流。
answerstring#
完整的响应内容。
created_atinteger#
消息创建时间戳(Unix 纪元秒)。
eventstring#
事件类型,固定为 message。
idstring#
该响应事件的唯一 ID。
message_idstring#
唯一的消息 ID。调用反馈或推荐问题接口时,将此值作为 message_id 参数使用。
metadataobject#
包含用量和检索资源的元数据。
modestring#
应用模式,固定为 completion。
task_idstring#
用于请求追踪和 停止响应 API 的任务 ID。