ModelResponse

@Serializable
class ModelResponse(val id: String, val object: String, val createdAt: Long, val status: ResponseStatus, val error: ResponseError? = null, val incompleteDetails: IncompleteDetails? = null, val model: String, val output: List<ResponseItem> = emptyList(), val usage: ResponseUsage? = null)

A response produced by the Responses API.

output lists the items the model produced, in order: the ReasoningItem of a thinking model comes first, then the assistant MessageItem, with FunctionCallItem and WebSearchCallItem interleaved as the model calls tools. Because the API is stateless, feeding output straight back into the next request's input is what continues the conversation.

Example:

val response = client.createResponse("What is the capital of France?")
println(response.outputText)
println(response.usage?.totalTokens)

See also

Constructors

Link copied to clipboard
constructor(id: String, object: String, createdAt: Long, status: ResponseStatus, error: ResponseError? = null, incompleteDetails: IncompleteDetails? = null, model: String, output: List<ResponseItem> = emptyList(), usage: ResponseUsage? = null)

Properties

Link copied to clipboard

Unix timestamp, in seconds, of when the response was created.

Link copied to clipboard

Set when status is ResponseStatus.FAILED, describing what went wrong.

Link copied to clipboard

The function calls in output, in the order the model emitted them.

Link copied to clipboard
val id: String

Unique identifier of the response.

Link copied to clipboard

Set when status is ResponseStatus.INCOMPLETE, saying why the response was cut short.

Link copied to clipboard

Model that produced the response.

Link copied to clipboard

Object type discriminator; always response.

Link copied to clipboard

Items the model produced, in generation order.

Link copied to clipboard

Text of every OutputTextPart the model produced, concatenated in order.

Link copied to clipboard

Whether the response completed, was truncated, or failed.

Link copied to clipboard

Token usage statistics; absent while the response is still in progress.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String