Skip to main content

AI 对话:额度与会话列表

AI 对话 REST 接口的公共前缀为:

https://ydzx.panretro.com/external/api/v1/sseStream/

所有接口都需要 OAuth2 access token,且令牌必须包含 chat scope。令牌可按现有 OAuth2 文档获取;请求时通过 Authorization: Bearer {accessToken}access_token 参数传入。

接口只返回当前 token 所属用户的数据,不能用会话 ID 读取其他用户的会话。

查询额度

GET /external/api/v1/sseStream/quota

响应中的 messageCount 是当前统计周期已完成的 AI 回复条数,tokenCount 是累计总 token 数。实际限制由 allocationUnit 决定:count 表示按条数限制,token 表示按 token 限制。

{
"code": 200,
"msg": "success",
"data": {
"messageCount": 12,
"tokenCount": 8304,
"allocationUnit": "count",
"allocationMax": 100000,
"allocationPeriod": "daily",
"lastReset": 1760000000000,
"nextReset": 1760086400000
}
}
字段类型说明
messageCountlong当前周期已计入额度的回复条数
tokenCountlong当前周期累计 token 数
allocationUnitstringcounttoken
allocationMaxlong当前周期额度上限
allocationPeriodstringdailyweeklymonthly
lastReset / nextResetlong周期起止时间,Unix 毫秒时间戳

查询会自动处理已经过期的统计周期;因此返回值始终是当前周期的数据。

获取聊天列表

GET /external/api/v1/sseStream/conversations?page=1&pageSize=20
参数类型必填默认值说明
pageint1页码,从 1 开始
pageSizeint20每页数量,范围 1–100
{
"code": 200,
"msg": "success",
"data": {
"page": 1,
"pageSize": 20,
"total": 2,
"list": [
{
"id": 1950000000000000000,
"userId": 10001,
"title": "数据库索引设计",
"status": 1,
"defaultModel": "deepseek-chat",
"lastMessage": "2026-08-10T10:00:00.000+00:00",
"totalToken": 8304
}
]
}
}

会话列表只包含持久化的会话元数据。WebSocket setting 帧中的系统提示词和输出长度是连接内的临时状态,不会出现在此接口,也不会写入数据库。