Uploads API

Resumable, multi-part uploads for large files — beyond the single-request limit of the Files API. Create an upload, add its parts, then complete it to receive a FileObject. OpenAI only.

Objects

UniLM.UploadObjectType
UploadObject

A resumable upload session: id, status, filename, and bytes; once the upload is completed, file holds the resulting FileObject. raw holds the unparsed JSON response.

source

Result Types

Request Functions

UniLM.create_uploadFunction
create_upload(; filename, purpose, bytes, mime_type, service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.add_upload_partFunction
add_upload_part(upload_id, data::Vector{UInt8}; service=OPENAIServiceEndpoint)  (multipart)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.complete_uploadFunction
complete_upload(upload_id, part_ids; md5=nothing, service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.cancel_uploadFunction
cancel_upload(upload_id; service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source

Usage

# Start a resumable upload for a large file
up = create_upload(filename="big.jsonl", purpose="batch",
                   bytes=filesize("big.jsonl"), mime_type="application/jsonl")

# Add one or more parts, collecting their ids
part = add_upload_part(up.response.id, read("big.jsonl"))
part_ids = [part.response.id]

# Complete to finalize (yields a FileObject), or cancel to abort
done = complete_upload(up.response.id, part_ids)
done isa UploadSuccess && println("File: ", done.response.file.id)
# cancel_upload(up.response.id)