Learn R Programming

openaiRtools (version 0.2.2)

create_upload: Create a Multipart Upload Session (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and initializes a multipart upload session. Use this when your file exceeds the 512 MB single-upload limit.

Usage

create_upload(purpose, filename, bytes, ...)

Value

An upload object with $id (use in add_upload_part() and complete_upload()).

Arguments

purpose

Character. Required. The intended use: "assistants", "batch", or "fine-tune".

filename

Character. Required. The original name of the file.

bytes

Integer. Required. Total file size in bytes (file.info("myfile.jsonl")$size).

...

Additional parameters passed to UploadsClient$create(), such as mime_type.

Examples

Run this code
if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")

file_size <- file.info("huge_training.jsonl")$size
upload <- create_upload(
  purpose   = "fine-tune",
  filename  = "huge_training.jsonl",
  bytes     = file_size,
  mime_type = "application/json"
)
cat("Upload ID:", upload$id)
}

Run the code above in your browser using DataLab