上传文件分片
POST
/file/v1/uploads/{upload_id}/parts◐ 部分支持请求参数
upload_idstring必填path: Upload identifier returned by create; belongs to your organization.
part_numberinteger可选query: Required when create set part_size; 1 through ceil(bytes / part_size). Ignored for general uploads.
datastring必填Raw bytes of this part, nonempty and at most 64000000 bytes.
返回
200 upload.part
每片最多 64 MB,总量最多 20 GiB。仅支持 user_data、assistants、vision;未完成上传 7 天后过期。可用 GET /file/v1/uploads/{upload_id} 查询已收到的分片,只补传缺失的分片再完成。流程:创建 → 传片 → 查询 → 补传 → 完成;完成后须等文件处理完成才能使用。
错误按 OpenAI 格式返回,参见 错误码
请求示例
curl
curl "https://api.deepraxis.com/file/v1/uploads/upload_123/parts?part_number=1" \
-H "Authorization: Bearer $PRAXIS_API_KEY" -F "data=@part-1.txt"Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.deepraxis.com/file/v1",
api_key="$PRAXIS_API_KEY",
)
# Split document.txt into 5 MiB, 5 MiB and 1 MiB parts. Use the ID from create.
with open("part-1.txt", "rb") as data:
part = client.uploads.parts.create("upload_123", data=data, extra_query={"part_number": 1})
print(part.id)TypeScript
import OpenAI from "openai";
import fs from "node:fs";
const client = new OpenAI({
baseURL: "https://api.deepraxis.com/file/v1",
apiKey: "$PRAXIS_API_KEY",
});
// Split document.txt into 5 MiB, 5 MiB and 1 MiB parts. Use the ID from create.
const part = await client.uploads.parts.create("upload_123", { data: fs.createReadStream("part-1.txt") }, { query: { part_number: 1 } });
console.log(part.id);响应示例 200
{
"id": "part_pBc2UEZSzBuhw3HhyYP9bduM",
"object": "upload.part",
"created_at": 1792684740,
"upload_id": "upload_XTVtShoLFqNNohPQSkj7RVrz",
"bytes": 5242880,
"sha256": "sha256:dbbe5517996826bd5861ac22b745d21d11219055d89243ca1aea0ad31f552b12"
}响应
HTTP 200
The part was accepted.
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Part identifier returned by this request. Supply it to complete in file byte order. |
| object | string | Object type; upload.part identifies an uploaded part. |
| created_at | integer | Part creation time as Unix seconds. |
| upload_id | string | Parent upload identifier supplied in the request path. |
| bytes | integer | Accepted part length in bytes. |
| sha256 | string | Part content digest prefixed sha256:. |