Skip to content

会话 API

会话(对话线程)的增删改查。

版本说明:会话能力在代码中以 /api/v1/chat/conversations 实现,不存在 /api/v1/sessions 这一路由。两者都提供。


GET /api/v1/chat/conversations

获取会话列表(分页)。

查询参数: page(默认 1)、page_size(默认 20)、filteractive 默认 / archived)。

响应:

json
{
  "code": 0,
  "data": {
    "items": [
      {
        "id": "conv_xxx",
        "title": "讨论天气",
        "model": "lyncore-chat",
        "created_at": "2026-08-05T10:00:00Z",
        "updated_at": "2026-08-05T10:05:00Z",
        "message_count": 12
      }
    ],
    "total": 42,
    "page": 1,
    "page_size": 20
  },
  "message": "ok",
  "request_id": "req_abc123"
}

POST /api/v1/chat/conversations

创建新会话。

请求:

json
{ "title": "新对话", "agent_id": "agent_xxx(可选)" }

搜索会话(按标题/内容关键词)。

查询参数: q(关键词)、pagepage_size


GET /api/v1/chat/conversations/:id

获取会话详情(含消息历史)。

响应:

json
{
  "code": 0,
  "data": {
    "id": "conv_xxx",
    "title": "讨论天气",
    "messages": [
      { "id": "msg_xxx", "role": "user", "content": "你好", "created_at": "2026-08-05T10:00:00Z" },
      { "id": "msg_yyy", "role": "assistant", "content": "你好!有什么可以帮你的?", "tool_calls": [], "created_at": "2026-08-05T10:00:02Z" }
    ],
    "has_more": true
  },
  "message": "ok",
  "request_id": "req_abc123"
}

PATCH /api/v1/chat/conversations/:id

更新会话属性(如标题、归档状态)。

请求:

json
{ "title": "新标题", "archived": false }

DELETE /api/v1/chat/conversations/:id

删除会话(软删除/归档)。


说明:消息历史随会话详情一并返回;代码中没有独立的 /api/v1/sessions/:id/messages/export 路由。