Learn R Programming

openaiRtools (version 0.2.2)

retrieve_response: Retrieve a Response (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and retrieves a stored response by its ID. Only responses created with store = TRUE can be retrieved.

Usage

retrieve_response(response_id)

Value

A response object with $output, $model, and $usage.

Arguments

response_id

Character. Required. The response ID (e.g. "resp_abc123").

Examples

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

resp <- retrieve_response("resp_abc123")
cat(resp$output[[1]]$content[[1]]$text)
}

Run the code above in your browser using DataLab