Learn R Programming

openaiRtools (version 0.2.2)

retrieve_file_content: Retrieve File Content (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and downloads the raw content of a file.

Usage

retrieve_file_content(file_id)

Value

A raw vector of binary content. Use rawToChar() for text, or writeBin() to save to disk.

Arguments

file_id

Character. Required. The file ID to download.

Examples

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

# Download batch output file
raw_data <- retrieve_file_content("file-abc123")
text <- rawToChar(raw_data)
cat(text)

# Save to file
writeBin(raw_data, "batch_results.jsonl")
}

Run the code above in your browser using DataLab