跳转到主要内容
POST
/
completion-messages
{
  "id": "0b089b9a-24d9-48cc-94f8-762677276261",
  "message_id": "0b089b9a-24d9-48cc-94f8-762677276261",
  "mode": "chat",
  "answer": "how are you?",
  "metadata": {},
  "created_at": 1679586667
}

Authorizations

Authorization
string
header
required

API-Key 鉴权。所有 API 请求都应在 Authorization HTTP Header 中包含你的 API-Key,格式为 Bearer {API_KEY}强烈建议开发者把 API-Key 放在后端存储,而非分享或者放在客户端存储,以免 API-Key 泄露,导致财产损失。

Body

application/json

创建完成消息的请求体。

inputs
object
required

(选填)允许传入 App 定义的各变量值。inputs 参数包含了多组键值对,每组的键对应一个特定变量,值则是该变量的具体值。文本生成型应用要求至少传入一组键值对。

response_mode
enum<string>
required

响应返回模式。streaming:流式模式(推荐),基于 SSE 实现打字机输出。blocking:阻塞模式,等待执行完毕后返回(长流程可能中断)。Cloudflare 限制为 100 秒超时。

可用选项:
streaming,
blocking
user
string
required

用户标识,用于定义终端用户的身份,方便检索、统计。由开发者定义规则,需保证用户标识在应用内唯一。

files
object[]

上传的文件列表(目前仅支持图片)。

  • Option 1
  • Option 2

Response

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

  • response_modeblocking,返回 application/jsonChatCompletionResponse 对象。
  • response_modestreaming,返回 text/event-streamChunkChatCompletionResponse 流式序列。

阻塞模式下的完整 App 结果。

message_id
string<uuid>

消息唯一 ID。

mode
string

App 模式,固定为 chat

Example:

"chat"

answer
string

完整回复内容。

metadata
object

元数据。

created_at
integer

消息创建时间戳,如:1705395332。