The ModelResponse class represents a model response object in the OpenAI API.
Public fields
backgroundLogical. Whether to run the model response in the background.
conversationCharacter or list. The conversation that this response belongs to.
idCharacter. Unique identifier for this Response.
errorList or NULL. An error object returned when the model fails to generate a Response.
incomplete_detailsList or NULL. Details about why the response is incomplete.
created_atNumeric. Unix timestamp (in seconds) of when this Response was created.
instructionsCharacter or NULL. Inserts a system (or developer) message as the first item in the model's context.
max_output_tokensInteger 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_callsInteger or NULL. The maximum number of total calls to built-in tools that can be processed in a response.
metadataList. Set of 16 key-value pairs that can be attached to an object.
modelCharacter. Model ID used to generate the response, like gpt-4o or o1.
outputList. An array of content items generated by the model.
output_textCharacter 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_callsLogical. Whether to allow the model to run tool calls in parallel.
previous_response_idCharacter or NULL. The unique ID of the previous response to the model.
promptList or NULL. Reference to a prompt template and its variables.
prompt_cache_keyCharacter or NULL. Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the
userfield.reasoningList or NULL. Configuration options for reasoning models.
safety_identifierCharacter or NULL. A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.
service_tierCharacter or NULL. The latency tier to use for processing the request.
statusCharacter. The status of the response generation.
temperatureNumeric or NULL. What sampling temperature to use, between 0 and 2.
textList. Configuration options for a text response from the model.
tool_choiceCharacter or List. How the model should select which tool (or tools) to use when generating a response.
toolsList. An array of tools the model may call while generating a response.
top_logprobsInteger 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_pNumeric or NULL. An alternative to sampling with temperature, called nucleus sampling.
truncationCharacter or NULL. The truncation strategy to use for the model response.
usageList. Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
userCharacter. A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
verbosityCharacter 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)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())