Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Upload Model

From Leeroopedia
Revision as of 13:41, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Upload_Model.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for representing an Upload object returned by the OpenAI Uploads API, provided by the openai-python SDK.

Description

Upload is a Pydantic BaseModel subclass that represents the Upload resource from the OpenAI API. The Upload object can accept byte chunks in the form of Parts. It tracks the lifecycle of a multi-part file upload including its status (pending, completed, cancelled, or expired), the intended purpose of the file, and an optional reference to the completed FileObject.

Usage

Import this type when you need to type-annotate or inspect the response from upload creation, retrieval, or completion endpoints. The model is returned by methods such as client.uploads.create(), client.uploads.complete(), and client.uploads.cancel().

Code Reference

Source Location

Signature

class Upload(BaseModel):
    """The Upload object can accept byte chunks in the form of Parts."""

    id: str
    bytes: int
    created_at: int
    expires_at: int
    filename: str
    object: Literal["upload"]
    purpose: str
    status: Literal["pending", "completed", "cancelled", "expired"]
    file: Optional[FileObject] = None

Import

from openai.types import Upload

I/O Contract

Fields

Name Type Required Description
id str Yes The Upload unique identifier, which can be referenced in API endpoints.
bytes int Yes The intended number of bytes to be uploaded.
created_at int Yes The Unix timestamp (in seconds) for when the Upload was created.
expires_at int Yes The Unix timestamp (in seconds) for when the Upload will expire.
filename str Yes The name of the file to be uploaded.
object Literal["upload"] Yes The object type, which is always "upload".
purpose str Yes The intended purpose of the file.
status Literal["pending", "completed", "cancelled", "expired"] Yes The status of the Upload.
file Optional[FileObject] No The File object representing a document uploaded to OpenAI.

Usage Examples

from openai import OpenAI
from openai.types import Upload

client = OpenAI()

# Create an upload
upload: Upload = client.uploads.create(
    bytes=1024 * 1024,
    filename="training_data.jsonl",
    mime_type="application/jsonl",
    purpose="fine-tune",
)

print(upload.id)           # "upload_abc123"
print(upload.status)       # "pending"
print(upload.expires_at)   # Unix timestamp

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment