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.UploadObject — Type
UploadObjectA resumable upload session: id, status, filename, and bytes; once the upload is completed, file holds the resulting FileObject. raw holds the unparsed JSON response.
UniLM.UploadPartObject — Type
UploadPartObjectA single uploaded part; its id is passed to complete_upload to assemble the final file. raw holds the unparsed JSON response.
Result Types
UniLM.UploadSuccess — Type
Successful create/complete/cancel result wrapping an UploadObject.
UniLM.UploadPartSuccess — Type
Successful add_upload_part result wrapping an UploadPartObject.
UniLM.UploadFailure — Type
Uploads API error result: HTTP status and the raw response body.
UniLM.UploadCallError — Type
Local/transport error from an Uploads API call (the request never completed).
Request Functions
UniLM.create_upload — Function
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).
UniLM.add_upload_part — Function
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).
UniLM.complete_upload — Function
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).
UniLM.cancel_upload — Function
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).
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)