文件接口
批处理输入文件的上传、查询、下载与删除。上传的文件
purpose固定为batch;成功/失败结果文件(batch_output/batch_error)由平台生成,只能下载,不能上传。文件对象字段说明见 接口概览 · 文件对象。
权限范围
文件完全按 API Key 隔离,只能由上传它的 API Key 查询、下载和删除,其他 API Key 访问一律返回 404 file_not_found(同一账号或同一企业下的其他 API Key 也不例外);结果文件归属于创建任务的 API Key。详见 接口概览 · 数据可见范围。
上传文件
接口地址
http
POST /v1/files请求头
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | Bearer <api-key> |
Content-Type | string | 是 | multipart/form-data |
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
purpose | string | 是 | 固定 batch |
file | file | 是 | JSONL 文件,每行一个 JSON 对象 |
上传限制
| 限制 | 默认值 | 超限返回 |
|---|---|---|
| 文件字节数 | 100 MB | 400 / 413 file_too_large |
| 有效行数 | 50,000 | 400 too_many_rows |
| 单行长度 | 8 MB | 400 invalid_jsonl |
| 空文件 | — | 400 empty_file |
| 文件保留期 | 30 天 | 过期后读取返回 404 file_not_found |
上传仅校验文件为合法 JSONL;行内的
custom_id、model、url等结构在创建任务时校验。
请求示例
bash
curl --request POST \
--url 'https://neolink.com/api/v1/files' \
--header 'Authorization: Bearer <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form 'purpose=batch' \
--form 'file=@batch1.jsonl'成功响应
json
{
"id": "file-51428aca4e0a47808012aaa03d1734ff",
"object": "file",
"bytes": 512,
"created_at": 1764031200,
"filename": "batch1.jsonl",
"purpose": "batch"
}响应字段说明见 接口概览 · 文件对象。
错误响应
| HTTP | code | 说明 |
|---|---|---|
| 400 | missing_file | 缺少 file 表单参数 |
| 400 | invalid_purpose | purpose 不是 batch |
| 400 | invalid_jsonl | 文件不是合法 JSONL,或单行超过 8 MB |
| 400 | empty_file | 文件没有任何有效行 |
| 400 | too_many_rows | 有效行数超过上限 |
| 400 | file_too_large | 文件字节数超过上限 |
| 403 | no_batch_group | 当前 API Key 未开通批处理 |
| 403 | no_batch_channel | 当前配置暂不支持批处理 |
| 413 | file_too_large | 上传内容超过大小上限 |
| 503 | object_storage_unconfigured | 批处理服务暂不可用 |
查询文件列表
接口地址
http
GET /v1/files请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
purpose | string | 否 | 按用途过滤:batch / batch_output / batch_error |
limit | int | 否 | 每页条数,默认 20,最大 100(超上限按 100 截断) |
after | string | 否 | 游标:上一页返回的 last_id;首页不传 |
请求示例
bash
curl --location 'https://neolink.com/api/v1/files?purpose=batch&limit=20' \
--header 'Authorization: Bearer <api-key>'成功响应
json
{
"object": "list",
"data": [
{
"id": "file-51428aca4e0a47808012aaa03d1734ff",
"object": "file",
"bytes": 512,
"created_at": 1764031200,
"filename": "batch1.jsonl",
"purpose": "batch"
}
],
"has_more": false,
"first_id": "file-51428aca4e0a47808012aaa03d1734ff",
"last_id": "file-51428aca4e0a47808012aaa03d1734ff"
}| 字段 | 类型 | 说明 |
|---|---|---|
object | string | 固定 list |
data | array | 文件对象数组,按 created_at 倒序 |
has_more | bool | 是否还有下一页 |
first_id | string | null | 本页第一个文件标识,空列表时为 null |
last_id | string | null | 本页最后一个文件标识,下一页传给 after |
错误响应
| HTTP | code | 说明 |
|---|---|---|
| 400 | invalid_limit | limit 不是正整数 |
| 400 | invalid_after | after 游标非法或指向不存在的文件 |
查询文件详情
接口地址
http
GET /v1/files/{id}请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 文件标识 file-... |
请求示例
bash
curl --location 'https://neolink.com/api/v1/files/file-51428aca4e0a47808012aaa03d1734ff' \
--header 'Authorization: Bearer <api-key>'成功响应
返回单个文件对象,字段见 接口概览 · 文件对象。
错误响应
| HTTP | code | 说明 |
|---|---|---|
| 404 | file_not_found | 文件不存在或不属于当前 API Key |
下载文件内容
接口地址
http
GET /v1/files/{id}/content请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 文件标识 file-... |
请求示例
bash
curl --location 'https://neolink.com/api/v1/files/file-fa7326de39c3402cbc12007522f78c69/content' \
--header 'Authorization: Bearer <api-key>' \
-o output.jsonl成功响应
直接返回文件内容(流式):
| 响应头 | 值 |
|---|---|
Content-Type | application/jsonl |
Content-Disposition | attachment; filename="<filename>" |
Content-Length | 文件字节数(大于 0 时返回) |
错误响应
| HTTP | code | 说明 |
|---|---|---|
| 404 | file_not_found | 文件不存在、不属于当前 API Key 或已过期 |
删除文件
接口地址
http
DELETE /v1/files/{id}请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 文件标识 file-... |
请求示例
bash
curl --request DELETE \
--url 'https://neolink.com/api/v1/files/file-51428aca4e0a47808012aaa03d1734ff' \
--header 'Authorization: Bearer <api-key>'成功响应
json
{
"id": "file-51428aca4e0a47808012aaa03d1734ff",
"object": "file",
"deleted": true
}错误响应
| HTTP | code | 说明 |
|---|---|---|
| 409 | file_in_use | 输入文件仍被未结束的任务使用,或结果文件所属任务尚未处理完成 |
| 404 | file_not_found | 文件不存在或不属于当前 API Key |
