The ModelResponse
class represents a model response object in the OpenAI API.
Public fields
background
Logical. Whether to run the model response in the background.
id
Character. Unique identifier for this Response.
error
List or NULL. An error object returned when the model fails to generate a Response.
incomplete_details
List or NULL. Details about why the response is incomplete.
created_at
Numeric. Unix timestamp (in seconds) of when this Response was created.
instructions
Character or NULL. Inserts a system (or developer) message as the first item in the model's context.
max_output_tokens
Integer or NULL. An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
max_tool_calls
Integer or NULL. The maximum number of total calls to built-in tools that can be processed in a response.
metadata
List. Set of 16 key-value pairs that can be attached to an object.
model
Character. Model ID used to generate the response, like gpt-4o or o1.
output
List. An array of content items generated by the model.
output_text
Character or NULL. SDK-only convenience property that contains the aggregated text output from all output_text items in the output array, if any are present.
parallel_tool_calls
Logical. Whether to allow the model to run tool calls in parallel.
previous_response_id
Character or NULL. The unique ID of the previous response to the model.
prompt
List or NULL. Reference to a prompt template and its variables.
prompt_cache_key
Character or NULL. Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the
user
field.reasoning
List or NULL. Configuration options for reasoning models.
safety_identifier
Character or NULL. A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.
service_tier
Character or NULL. The latency tier to use for processing the request.
status
Character. The status of the response generation.
temperature
Numeric or NULL. What sampling temperature to use, between 0 and 2.
text
List. Configuration options for a text response from the model.
tool_choice
Character or List. How the model should select which tool (or tools) to use when generating a response.
tools
List. An array of tools the model may call while generating a response.
top_logprobs
Integer or NULL. An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
top_p
Numeric or NULL. An alternative to sampling with temperature, called nucleus sampling.
truncation
Character or NULL. The truncation strategy to use for the model response.
usage
List. Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
user
Character. A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
verbosity
Character or NULL. Constrains the verbosity of the model's response.
Methods
Method new()
Initialize a ModelResponse
object.
Usage
ModelResponse$new(
response_id = NULL,
input = NULL,
...,
resp = NULL,
.async = TRUE
)
Arguments
response_id
Character. Unique identifier for this Response.
input
Character or List. Text, image, or file inputs to the model, used to generate a response.
...
Additional parameters to pass to the model.
resp
List. The response object returned by the OpenAI API.
.async
Logical. Whether to retrieve the response asynchronously.
Method get()
Get a fresh copy of the model response.
Method do_tool_calls()
Do all tool calls in the model response and return the results.
Usage
ModelResponse$do_tool_calls(env = parent.frame())
Method wait()
Submit tool outputs to generate a new model response.
Usage
ModelResponse$wait(env = parent.frame())
Method await()
Wait for the model response to complete.
Usage
ModelResponse$await(env = parent.frame())