Skip to contents

Retrieves the status object for a specified OpenAI batch job ID and prints a concise, human-friendly summary of the current status (e.g., completed, failed, in progress with percentage). The full status object is returned invisibly.

Usage

check_batch(batch_id, timeout = 60)

Arguments

batch_id

Character string. The ID of the OpenAI batch job (e.g., "batch_abc123"). Required.

timeout

Numeric. Request timeout in seconds. Default is 60.

Value

Invisibly returns a list representing the parsed JSON response (the full batch object) from the OpenAI API. This includes status, file IDs (if generated), timestamps, request counts, etc. Returns NULL visibly and prints an error message if the API call fails. If the call succeeds, it prints a summary message (using cli) to the console before returning the full object invisibly.

Examples

if (FALSE) { # \dontrun{
# Assuming you have a batch ID from single_turns(..., batch = TRUE)
# Sys.setenv(OPENAI_API_KEY = "YOUR_OPENAI_KEY")
my_batch_id <- "batch_xxxxxxxxxxxx" # Replace with your actual batch ID

# Run the check - it will PRINT the summary
check_batch(my_batch_id)

# If you need the full details programmaticallly, assign the result
full_status <- check_batch(my_batch_id)
# It still prints the summary, but full_status now holds the list
if (!is.null(full_status)) {
  print(paste("Programmatic access to status:", full_status$status))
}
} # }