添加会话条目

向本地会话添加一条类型、角色和状态摘要。

POST https://token.moi.matrixorigin.cn/v1/conversations/{conversation_id}/items

调用前准备

  1. 准备具有 Genesis 权限的个人访问令牌

  2. 使用创建会话时的凭据,选择尚未删除、尚未关联上游模型的本地会话。

请求示例

将示例中的 $GENESIS_ACCESS_TOKEN$CONVERSATION_ID 分别替换为个人访问令牌和所选会话的 ID。

curl -X POST "https://token.moi.matrixorigin.cn/v1/conversations/$CONVERSATION_ID/items" \
  -H "Authorization: Bearer $GENESIS_ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "message",
  "role": "user"
}'

路径参数

参数

类型

是否必填

说明

conversation_id

string

创建会话响应中的 id

请求体

本地条目保存类型、角色和状态等摘要;消息正文需由应用自行保存。

参数

类型

是否必填

说明

type

string

条目类型,例如 message

role

string

条目角色,例如 user

status

string

条目状态,省略时为 active

成功响应

成功时返回新增的条目摘要。

{
  "id": "$ITEM_ID",
  "object": "conversation.item",
  "conversation_id": "$CONVERSATION_ID",
  "type": "message",
  "role": "user",
  "status": "active",
  "created_at": 1780000000
}

字段

类型

说明

id

string

条目标识。

object

string

固定为 conversation.item

conversation_id

string

条目所属的会话标识。

type

string

条目类型,例如 message

role

string

条目角色,例如 user

status

string

条目状态,省略时为 active

created_at

integer

创建时间,Unix 秒级时间戳。

错误响应

资源不存在、已删除或当前凭据不可访问时,请求返回 404

{
  "error": {
    "message": "conversation not found",
    "type": "conversation_not_found",
    "code": "conversation_not_found"
  }
}

字段

类型

说明

error

object

错误信息。

error.message

string

错误原因。

error.type

string

错误类别。

error.code

string

错误代码。

后续操作

保存响应中的 id,用于查询会话条目删除会话条目

最后更新于