Skip to content
中文

Create an upload

POST/openai/v1/uploads◐ Partial

Official OpenAI docs ↗

Request body

  • bytesintegerrequired

    Exact complete file length in bytes, from 1 through 21474836480 (20 GiB); the sum of completed parts must match.

  • filenamestringrequired

    Filename for the resulting file, at most 255 UTF-8 bytes.

  • mime_typestringrequired

    Declared MIME type; validated against the assembled content.

  • purposestringrequired

    Use user_data for conversation attachments, assistants for assistant files, or vision for PNG, JPEG, GIF and WebP images.

    values user_dataassistantsvision
  • expires_afterobjectoptional

    Optional expiry policy for the resulting file; omission retains the file until deletion.

    Expand sub-fields (2)
    • anchorstringoptional
      default "created_at"

      Expiry is measured from file creation; created_at is the only supported anchor.

      values created_at
    • secondsintegerrequired

      Resulting file lifetime in seconds; omit expires_after to retain it until deletion.

  • part_sizeintegeroptional

    Optional fixed part size in bytes, 5242880–64000000. Requires part_number on every part; retries of identical bytes at the same number return the same part. Omit to use arbitrary-sized parts.

Returns

200 upload

Parts are at most 64 MB and the total is at most 20 GiB. Only user_data, assistants and vision are accepted. Pending uploads expire after 7 days. Wait for file processing before use.

Errors follow the OpenAI format — see error codes

Request

curl
curl https://api.deepraxis.com/openai/v1/uploads \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"bytes":11534336,"filename":"document.txt","mime_type":"text/plain","purpose":"user_data","part_size":5242880}'
Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepraxis.com/openai/v1",
    api_key="$PRAXIS_API_KEY",
)

upload = client.uploads.create(bytes=11534336, filename="document.txt", mime_type="text/plain", purpose="user_data", extra_body={"part_size": 5242880})
print(upload.id)
TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.deepraxis.com/openai/v1",
  apiKey: "$PRAXIS_API_KEY",
});

const upload = await client.uploads.create({ bytes: 11534336, filename: "document.txt", mime_type: "text/plain", purpose: "user_data", ...{ part_size: 5242880 } });
console.log(upload.id);

Response 200

{
  "id": "upload_iFZqxf1kveCAvf54fbudiIRn",
  "object": "upload",
  "bytes": 11534336,
  "created_at": 1792685010,
  "expires_at": 1792688610,
  "filename": "document.txt",
  "purpose": "user_data",
  "status": "pending",
  "file": null
}

Response

HTTP 200

The upload state and, after completion, the resulting file.

application/json

Name Type Description
id string Upload identifier returned by create. Use this value for parts, complete and cancel.
object string Object type; upload identifies an upload session.
bytes integer Declared size of the complete file in bytes.
created_at integer Creation time as Unix seconds.
expires_at integer Expiry time as Unix seconds; unfinished uploads expire after 7 days.
filename string Filename supplied when creating the upload.
purpose string File purpose: user_data for conversation attachments, assistants for assistant files, vision for images.
status string Upload state: pending accepts parts; completed has a file; cancelled was cancelled; expired exceeded its seven-day lifetime.
file object | null Present after complete. A file with status uploaded is still processing; poll files.retrieve until processed before use.
file.id string The file identifier, which can be referenced in the API endpoints.
file.bytes integer The size of the file, in bytes.
file.created_at integer The Unix timestamp (in seconds) for when the file was created.
file.expires_at integer The Unix timestamp (in seconds) for when the file will expire.
file.filename string The name of the file.
file.object string The object type, which is always file.
file.purpose string The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, and user_data.
file.status string Deprecated. The current status of the file, which can be either uploaded, processed, or error.
file.status_details string Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.