OpenAIResponsesResponse

@Serializable
data class OpenAIResponsesResponse(val id: String, val obj: String = "response", val createdAt: Long? = null, val completedAt: Long? = null, val status: OpenAIResponseStatus? = null, val error: OpenAIResponseError? = null, val output: List<OpenAIResponseOutputItem>, val incompleteDetails: OpenAIIncompleteDetails? = null, val instructions: String? = null, val model: String? = null, val maxOutputTokens: Int? = null, val maxToolCalls: Int? = null, val parallelToolCalls: Boolean? = null, val previousResponseId: String? = null, val reasoning: OpenAIReasoning? = null, val store: Boolean? = null, val temperature: Double? = null, val topP: Double? = null, val truncation: OpenAITruncation? = null, val text: OpenAIResponsesText? = null, val toolChoice: OpenAIToolChoice? = null, val tools: List<JsonElement> = emptyList(), val usage: OpenAIResponsesUsage? = null, val toolUsage: OpenAIResponsesToolUsage? = null, val serviceTier: OpenAIServiceTier? = null, val metadata: OpenAIMetadata? = null, val background: Boolean? = null, val user: String? = null, val safetyIdentifier: String? = null, val promptCacheKey: String? = null)

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

Link copied to clipboard
constructor(id: String, obj: String = "response", createdAt: Long? = null, completedAt: Long? = null, status: OpenAIResponseStatus? = null, error: OpenAIResponseError? = null, output: List<OpenAIResponseOutputItem>, incompleteDetails: OpenAIIncompleteDetails? = null, instructions: String? = null, model: String? = null, maxOutputTokens: Int? = null, maxToolCalls: Int? = null, parallelToolCalls: Boolean? = null, previousResponseId: String? = null, reasoning: OpenAIReasoning? = null, store: Boolean? = null, temperature: Double? = null, topP: Double? = null, truncation: OpenAITruncation? = null, text: OpenAIResponsesText? = null, toolChoice: OpenAIToolChoice? = null, tools: List<JsonElement> = emptyList(), usage: OpenAIResponsesUsage? = null, toolUsage: OpenAIResponsesToolUsage? = null, serviceTier: OpenAIServiceTier? = null, metadata: OpenAIMetadata? = null, background: Boolean? = null, user: String? = null, safetyIdentifier: String? = null, promptCacheKey: String? = null)

Properties

Link copied to clipboard

Whether the response was created as a background job. null when not included.

Link copied to clipboard
@SerialName(value = "completed_at")
val completedAt: Long?

Epoch timestamp when the response completed. null while the response is running.

Link copied to clipboard
@SerialName(value = "created_at")
val createdAt: Long?

Epoch timestamp when the response was created. null when not included.

Link copied to clipboard

The error, when the response status is failed. null otherwise.

Link copied to clipboard
val id: String

Unique identifier for this response.

Link copied to clipboard
@SerialName(value = "incomplete_details")
val incompleteDetails: OpenAIIncompleteDetails?

The reason the response is incomplete, when the status is incomplete. null otherwise.

Link copied to clipboard

The instructions (system prompt) the model used, as provided in the request. null when not included.

Link copied to clipboard
@SerialName(value = "max_output_tokens")
val maxOutputTokens: Int?

An upper bound for the number of tokens generated for this response. null when not set.

Link copied to clipboard
@SerialName(value = "max_tool_calls")
val maxToolCalls: Int?

An upper bound for the number of tool calls generated for this response. null when not set.

Link copied to clipboard

Metadata attached to the response. null when not included.

Link copied to clipboard

The model used for this response.

Link copied to clipboard
@SerialName(value = "object")
val obj: String

Object type (always "response").

Link copied to clipboard

The list of output items generated by the model (messages, tool calls, etc.).

Link copied to clipboard
Link copied to clipboard
@SerialName(value = "parallel_tool_calls")
val parallelToolCalls: Boolean?

Whether the model was allowed to run tool calls in parallel. null when not included.

Link copied to clipboard
@SerialName(value = "previous_response_id")
val previousResponseId: String?

The ID of the previous response in the same conversation chain. null when not included.

Link copied to clipboard
Link copied to clipboard
@SerialName(value = "prompt_cache_key")
val promptCacheKey: String?

A cache key used to route the request for prompt caching. null when not included.

Link copied to clipboard

The reasoning configuration the model used. null when not included.

Link copied to clipboard
@SerialName(value = "safety_identifier")
val safetyIdentifier: String?

A stable identifier used for safety/abuse tracking. null when not included.

Link copied to clipboard
@SerialName(value = "service_tier")
val serviceTier: OpenAIServiceTier?

The processing tier actually used to serve the request. null when not included.

Link copied to clipboard

The lifecycle status of the response: completed, failed, in_progress, cancelled, queued or incomplete. null when not included.

Link copied to clipboard

Whether the response was stored in the provider's storage. null when not included.

Link copied to clipboard

The sampling temperature used. null when not included.

Link copied to clipboard

Configuration for the text output (format, verbosity). null when not included.

Link copied to clipboard
@SerialName(value = "tool_choice")
val toolChoice: OpenAIToolChoice?

How the model was allowed to choose tools. null when not included.

Link copied to clipboard
val tools: List<JsonElement>

The tools available to the model for this response. null when not included.

Link copied to clipboard
@SerialName(value = "tool_usage")
val toolUsage: OpenAIResponsesToolUsage?

Token usage per hosted tool, when the response was metered per tool. null when not included.

Link copied to clipboard
@SerialName(value = "top_p")
val topP: Double?

The nucleus sampling top_p value used. null when not included.

Link copied to clipboard

The truncation strategy used for the response. null when not included.

Link copied to clipboard

Token usage statistics. null when not included (e.g. streaming events).

Link copied to clipboard
val user: String?

A stable identifier for the end user. null when not included.