GET /v1/files
获取当前账户下的文件列表。默认不返回 deleted 状态的文件。
请求头
| 头部 | 必选 | 说明 |
|---|---|---|
Authorization | 是 | Bearer <PAT> |
查询参数
| 参数 | 类型 | 必选 | 说明 |
|---|---|---|---|
limit | integer | 否 | 每页返回的最大文件数量。必须为正整数;默认 20,最大 100 |
after_id | string | 否 | 游标分页:返回此 file_id 之后的文件。不能与 before_id 同时传入 |
before_id | string | 否 | 游标分页:返回此 file_id 之前的文件。不能与 after_id 同时传入 |
order | string | 否 | 按 created_at 和 id 排序的方向。使用 asc 或 desc,默认 desc |
purpose | string | 否 | 按文件用途过滤,见 File purpose |
name | string | 否 | 按文件名前缀搜索,不区分大小写 |
session_id | string | 否 | 按关联 Session 过滤;未传 status 时,Session 范围列表只返回 ready 文件 |
status | string | 否 | 按 File status 过滤。传入时会覆盖默认的 deleted 排除逻辑 |
include_deleted | boolean | 否 | 未传 status 时,设为 true 可包含 deleted 状态文件 |
示例请求
示例响应
HTTP 200 OK响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
data | array | File 对象数组 |
first_id | string | null | 当前页第一个文件 ID;data 为空时为 null |
last_id | string | null | 当前页最后一个文件 ID;data 为空时为 null |
has_more | boolean | 是否还有更多文件 |
分页说明
结果按created_at 和 id 排序。遍历文件列表:
- 首次请求设置
limit获取第一页 - 如果
has_more为true,使用after_id=<last_id>获取下一页 - 使用
before_id=<first_id>可向前翻页
错误码
| HTTP | type | 触发条件 |
|---|---|---|
| 400 | invalid_request_error | limit 非法,或同时传入 before_id 与 after_id |
| 401 | authentication_error | 缺少或无效的认证令牌 |
相关
附加与下载文件
上传文件为 Agent 提供上下文,并下载 Agent 产出的文件。