Language model implementation for OpenAI's Responses API. This API is designed for stateful multi-turn conversations where the server maintains conversation history, and supports advanced features like:
Built-in reasoning/thinking (for o1, o3 models)
Server-side conversation state management via response IDs
Structured output items (reasoning, message, tool calls)
The Responses API uses a different request/response format than Chat Completions:
Request: input field instead of messages, optional previous_response_id
Response: output array with typed items instead of choices
aisdk::LanguageModelV1 -> OpenAIResponsesLanguageModel
new()Initialize the OpenAI Responses language model.
OpenAIResponsesLanguageModel$new(model_id, config, capabilities = list())model_idThe model ID (e.g., "o1", "o3-mini", "gpt-4o").
configConfiguration list with api_key, base_url, headers, etc.
capabilitiesOptional list of capability flags.
get_config()Get the configuration list.
OpenAIResponsesLanguageModel$get_config()A list with provider configuration.
get_last_response_id()Get the last response ID (for debugging/advanced use).
OpenAIResponsesLanguageModel$get_last_response_id()The last response ID or NULL.
reset()Reset the conversation state (clear response ID). Call this to start a fresh conversation.
OpenAIResponsesLanguageModel$reset()
do_generate()Generate text (non-streaming) using Responses API.
OpenAIResponsesLanguageModel$do_generate(params)paramsA list of call options including messages, temperature, etc.
A GenerateResult object.
do_stream()Generate text (streaming) using Responses API.
OpenAIResponsesLanguageModel$do_stream(params, callback)paramsA list of call options.
callbackA function called for each chunk: callback(text, done).
A GenerateResult object.
format_tool_result()Format a tool execution result for Responses API.
OpenAIResponsesLanguageModel$format_tool_result(
tool_call_id,
tool_name,
result_content
)tool_call_idThe ID of the tool call.
tool_nameThe name of the tool.
result_contentThe result content from executing the tool.
A list formatted as a message for Responses API.
get_history_format()Get the message format for Responses API.
OpenAIResponsesLanguageModel$get_history_format()
clone()The objects of this class are cloneable with this method.
OpenAIResponsesLanguageModel$clone(deep = FALSE)deepWhether to make a deep clone.