fix: restore OpenAPI file uploads

Expose /api/v1/file in OpenAPI, enable file-scoped API keys, and regenerate docs/client artifacts.
This commit is contained in:
Weilong Liao
2026-06-18 12:37:38 +08:00
committed by GitHub
parent 2c8f38c886
commit 264e7eaaa3
12 changed files with 411 additions and 29 deletions

View File

@@ -40,6 +40,7 @@ X-API-Key: abk_xxx
| `im` | 主动发 IM 消息、查询 bot/platform 列表 | `POST /api/v1/im/message``GET /api/v1/im/bots` |
| `config` | 管理配置文件、系统配置和通用配置。该 scope 同时包含 `bot``provider` 访问权限。 | `GET /api/v1/configs``GET/PUT /api/v1/system-config``GET/POST /api/v1/config-profiles` |
| `chat` | 调用对话能力、查询对话会话 | `POST /api/v1/chat``GET /api/v1/chat/sessions` |
| `file` | 上传和下载对话附件 | `POST /api/v1/file``GET /api/v1/file``POST /api/v1/files` |
| `plugin` | 管理插件、插件配置、插件源和插件市场 | `GET /api/v1/plugins``GET/PUT /api/v1/plugins/config``POST /api/v1/plugins/install/url` |
| `mcp` | 管理 MCP 服务器配置和服务端同步 | `GET/POST /api/v1/mcp/servers``PATCH /api/v1/mcp/servers/{server_name}/enabled``POST /api/v1/mcp/providers/modelscope/sync` |
| `skill` | 管理 Skills、Skill 压缩包、Skill 文件和 Shipyard Neo Skill 流程 | `GET/POST /api/v1/skills``PUT /api/v1/skills/{skill_name}/files/{file_path}``POST /api/v1/skills/neo/sync` |
@@ -48,7 +49,7 @@ X-API-Key: abk_xxx
`config` 是较大的管理 scope。创建 API Key 时如果包含 `config`AstrBot 会同时授予该 Key `config``bot``provider` 访问权限。WebUI 的勾选逻辑也会体现这个依赖关系:选中 `config` 会同时选中 `bot``provider`;取消选中 `bot``provider` 时,会同步取消 `config`
当前开发者 API Key 仅开放以上 9 个 scope。`file``tool``skills``kb``data``system` 暂不支持作为开发者 API Key scope。`/api/v1/skills/*` 接口使用单数 `skill` scope不使用复数 `skills`。公开 OpenAPI 文档只包含这些开发者 API Key scope 覆盖的接口。
当前开发者 API Key 仅开放以上 10 个 scope。`tool``skills``kb``data``system` 暂不支持作为开发者 API Key scope。`/api/v1/skills/*` 接口使用单数 `skill` scope不使用复数 `skills`。公开 OpenAPI 文档只包含这些开发者 API Key scope 覆盖的接口。
## 常用接口
@@ -59,6 +60,7 @@ X-API-Key: abk_xxx
- `POST /api/v1/chat`发送对话消息SSE 流式返回,不传 `session_id` 会自动创建 UUID
- `GET /api/v1/chat/sessions`:分页获取指定 `username` 的会话
- `GET /api/v1/configs`:获取可用配置文件列表
- `POST /api/v1/file`:上传附件,之后可在消息段中引用
**机器人和模型提供商**
@@ -121,7 +123,7 @@ X-API-Key: abk_xxx
说明:
- `attachment_id` 来自已存在的附件记录。开发者 API Key 当前不能使`POST /api/v1/file` 上传附件。
- `attachment_id` 来自已存在的附件记录,或使用 `file` scope 调`POST /api/v1/file` 上传附件后的返回值
- `reply` 不能单独作为唯一内容,至少需要一个有实际内容的段(如 `plain/image/file/...`)。
-`reply` 或空内容会返回错误。