跳转到内容
EN

上传文件分片

POST/openai/v1/uploads/{upload_id}/parts◐ 部分支持

OpenAI 官方文档 ↗

请求参数

  • 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 天后过期。完成后须等文件处理完成才能使用。

错误按 OpenAI 格式返回,参见 错误码

请求示例

curl
curl "https://api.deepraxis.com/openai/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/openai/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/openai/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_aptMkGcwMhM88UTytFfO0jqw",
  "object": "upload.part",
  "created_at": 1792685013,
  "upload_id": "upload_iFZqxf1kveCAvf54fbudiIRn"
}

响应

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.