OpenAIResponsesResponse
Raw OpenAI Responses API response.
Contains the full response from the /responses endpoint: the generated output items, token usage, tool usage metering and request echo fields (instructions, temperature, tools, etc.). Access the assistant's plain text with outputText, or inspect every generated item via output.
Example:
{
"id": "resp_67ccd3a9da748190baa7f1570fe91ac6",
"object": "response",
"created_at": 1741476777,
"completed_at": 1741476778,
"status": "completed",
"model": "gpt-5.6-sol",
"output": [
{ "type": "message", "id": "msg_abc", "role": "assistant",
"content": [{ "type": "output_text", "text": "Hi!" }], "status": "completed" }
],
"usage": { "input_tokens": 10, "output_tokens": 7, "total_tokens": 17 },
"incomplete_details": null,
"error": null,
"parallel_tool_calls": true,
"temperature": 1.0,
"tool_choice": "auto",
"tools": [],
"truncation": "disabled",
"service_tier": "default"
}Samples
// Response metadata.
println("id: ${response.id}")
println("model: ${response.model}")
println("status: ${response.status}")
println("serviceTier: ${response.serviceTier}")
// Failure / incompleteness details.
response.error?.let { println("error: ${it.code}: ${it.message}") }
response.incompleteDetails?.let { println("incompleteReason: ${it.reason}") }
// Token usage with detailed breakdowns.
response.usage?.let { usage ->
println("inputTokens: ${usage.inputTokens}")
println("outputTokens: ${usage.outputTokens}")
println("totalTokens: ${usage.totalTokens}")
println("cachedTokens: ${usage.inputTokensDetails?.cachedTokens}")
println("reasoningTokens: ${usage.outputTokensDetails?.reasoningTokens}")
}
// Hosted tool usage metering.
response.toolUsage?.let { toolUsage ->
toolUsage.webSearch?.let { println("webSearchRequests: ${it.numRequests}") }
toolUsage.imageGen?.let { println("imageGenTokens: ${it.totalTokens}") }
}
// Every generated output item.
for (item in response.output) {
when (item) {
is OpenAIResponsesOutputMessage -> println("message: ${response.outputText}")
is OpenAIResponsesReasoning -> println("reasoning: ${item.printableContent}")
is OpenAIResponsesFunctionCall ->
println("functionCall: ${item.name} ${item.arguments}")
is OpenAIResponsesWebSearchCall ->
println("webSearch: ${item.status}")
is OpenAIResponsesCodeInterpreterCall ->
println("codeInterpreter: ${item.code}")
is OpenAIResponsesImageGenerationCall ->
item.result?.let { println("image base64 length: ${it.length}") }
is OpenAIResponsesMcpCall ->
println("mcpCall: ${item.serverLabel}.${item.name} -> ${item.output}")
is OpenAIResponsesMcpApprovalRequest ->
println("needs approval: ${item.serverLabel}.${item.name}")
is OpenAIResponsesCustomToolCall ->
println("customToolCall: ${item.name} ${item.input}")
else -> println("item: ${item.printableContent}")
}
}Constructors
Properties
Whether the response was created as a background job. null when not included.
Epoch timestamp when the response completed. null while the response is running.
The error, when the response status is failed. null otherwise.
The reason the response is incomplete, when the status is incomplete. null otherwise.
The instructions (system prompt) the model used, as provided in the request. null when not included.
An upper bound for the number of tokens generated for this response. null when not set.
An upper bound for the number of tool calls generated for this response. null when not set.
Metadata attached to the response. null when not included.
The list of output items generated by the model (messages, tool calls, etc.).
Whether the model was allowed to run tool calls in parallel. null when not included.
The ID of the previous response in the same conversation chain. null when not included.
A cache key used to route the request for prompt caching. null when not included.
The reasoning configuration the model used. null when not included.
A stable identifier used for safety/abuse tracking. null when not included.
The processing tier actually used to serve the request. null when not included.
The lifecycle status of the response: completed, failed, in_progress, cancelled, queued or incomplete. null when not included.
The sampling temperature used. null when not included.
Configuration for the text output (format, verbosity). null when not included.
How the model was allowed to choose tools. null when not included.
Token usage per hosted tool, when the response was metered per tool. null when not included.
The truncation strategy used for the response. null when not included.
Token usage statistics. null when not included (e.g. streaming events).