Skip to contents

Retrieves batch metadata and downloads the raw JSONL file identified by error_file_id. This works even when the batch has no output_file_id. An error is raised if no valid error file ID is available; the message includes the batch ID and status. HTTP and local file-write errors propagate. An existing local file is overwritten only after its content is downloaded.

Usage

openai_download_batch_errors(batch_id, path, api_key = NULL)

Arguments

batch_id

The batch ID (e.g. "batch_abc123").

path

Local file path to write the downloaded error .jsonl file.

api_key

Optional OpenAI API key. Defaults to Sys.getenv("OPENAI_API_KEY").

Value

Invisibly, the path to the downloaded file.

Details

Successful requests are retrieved with openai_download_batch_output(). Reconcile both files against submitted requests by custom_id, not line order. This helper does not parse errors or retry failed comparisons.

Retrieval retries

Batch metadata and result-file GET requests retry HTTP 408, 429, all 5xx responses, and transport failures, with at most three total HTTP attempts per GET. Valid Retry-After seconds or HTTP dates take precedence; otherwise retries use exponential backoff starting at 0.5 seconds plus up to 0.25 seconds of jitter, capped at 30 seconds. Other HTTP errors fail immediately. Exhaustion raises the original error with the additional class pairwiseLLM_batch_retry_exhausted. These retries retrieve the same batch; they do not resubmit comparisons or create scientific failed-attempt rows.

Examples

if (FALSE) { # \dontrun{
# Requires OPENAI_API_KEY and a batch with an error_file_id.
openai_download_batch_errors("batch_abc123", "batch_errors.jsonl")
errors <- lapply(readLines("batch_errors.jsonl"), jsonlite::fromJSON)
} # }