Skip to content

文件接口 ​

批处理输入文件的上传、查询、下载与删除。上传的文件 purpose 固定为 batch;成功/失败结果文件(batch_output / batch_error)由平台生成,只能下载,不能上传。

文件对象字段说明见 接口概览 · 文件对象。

权限范围

文件完全按 API Key 隔离,只能由上传它的 API Key 查询、下载和删除,其他 API Key 访问一律返回 404 file_not_found(同一账号或同一企业下的其他 API Key 也不例外);结果文件归属于创建任务的 API Key。详见 接口概览 · 数据可见范围。

上传文件 ​

接口地址 ​

http
POST /v1/files

请求头 ​

参数名类型必填说明
Authorizationstring是Bearer <api-key>
Content-Typestring是multipart/form-data

请求参数 ​

字段类型必填说明
purposestring是固定 batch
filefile是JSONL 文件,每行一个 JSON 对象

上传限制 ​

限制默认值超限返回
文件字节数100 MB400 / 413 file_too_large
有效行数50,000400 too_many_rows
单行长度8 MB400 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"
}

响应字段说明见 接口概览 · 文件对象。

错误响应 ​

HTTPcode说明
400missing_file缺少 file 表单参数
400invalid_purposepurpose 不是 batch
400invalid_jsonl文件不是合法 JSONL,或单行超过 8 MB
400empty_file文件没有任何有效行
400too_many_rows有效行数超过上限
400file_too_large文件字节数超过上限
403no_batch_group当前 API Key 未开通批处理
403no_batch_channel当前配置暂不支持批处理
413file_too_large上传内容超过大小上限
503object_storage_unconfigured批处理服务暂不可用

查询文件列表 ​

接口地址 ​

http
GET /v1/files

请求参数 ​

字段类型必填说明
purposestring否按用途过滤:batch / batch_output / batch_error
limitint否每页条数,默认 20,最大 100(超上限按 100 截断)
afterstring否游标:上一页返回的 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"
}
字段类型说明
objectstring固定 list
dataarray文件对象数组,按 created_at 倒序
has_morebool是否还有下一页
first_idstring | null本页第一个文件标识,空列表时为 null
last_idstring | null本页最后一个文件标识,下一页传给 after

错误响应 ​

HTTPcode说明
400invalid_limitlimit 不是正整数
400invalid_afterafter 游标非法或指向不存在的文件

查询文件详情 ​

接口地址 ​

http
GET /v1/files/{id}

请求参数 ​

字段类型必填说明
idstring是文件标识 file-...

请求示例 ​

bash
curl --location 'https://neolink.com/api/v1/files/file-51428aca4e0a47808012aaa03d1734ff' \
  --header 'Authorization: Bearer <api-key>'

成功响应 ​

返回单个文件对象,字段见 接口概览 · 文件对象。

错误响应 ​

HTTPcode说明
404file_not_found文件不存在或不属于当前 API Key

下载文件内容 ​

接口地址 ​

http
GET /v1/files/{id}/content

请求参数 ​

字段类型必填说明
idstring是文件标识 file-...

请求示例 ​

bash
curl --location 'https://neolink.com/api/v1/files/file-fa7326de39c3402cbc12007522f78c69/content' \
  --header 'Authorization: Bearer <api-key>' \
  -o output.jsonl

成功响应 ​

直接返回文件内容(流式):

响应头值
Content-Typeapplication/jsonl
Content-Dispositionattachment; filename="<filename>"
Content-Length文件字节数(大于 0 时返回)

错误响应 ​

HTTPcode说明
404file_not_found文件不存在、不属于当前 API Key 或已过期

删除文件 ​

接口地址 ​

http
DELETE /v1/files/{id}

请求参数 ​

字段类型必填说明
idstring是文件标识 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
}

错误响应 ​

HTTPcode说明
409file_in_use输入文件仍被未结束的任务使用,或结果文件所属任务尚未处理完成
404file_not_found文件不存在或不属于当前 API Key