添加会话条目

向本地会话添加条目,记录条目的类型、角色和状态。

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

调用前准备

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

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

认证方式见 Genesis 凭据规则。

请求体

将示例中的 $CONVERSATION_ID、$GENESIS_ACCESS_TOKEN 替换为实际值。

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

是

条目所属的会话标识。

请求体

参数

类型

是否必填

说明

type

string

否

条目类型,例如 message。

role

string

否

条目角色,例如 user。

status

string

否

条目状态,省略时为 active。

请求体必须为 JSON 对象。metadata 用于保存自定义键值对。

成功响应

{
  "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

错误代码。

最后更新于