ResponseItem

@Serializable(with = ResponseItemSerializer::class)
sealed interface ResponseItem

One entry of the conversation handed to — or produced by — the Responses API.

The Responses API is stateless: the server keeps nothing between calls, so every turn resends the whole history. The same item types travel in both directions, which makes continuing a conversation a plain list append:

val history = mutableListOf<ResponseItem>(MessageItem(ResponseRole.USER, "What is 6 * 7?"))
val answer = client.createResponse(params, history)
history += answer.output
history += MessageItem(ResponseRole.USER, "And 6 * 8?")

An item whose type this version of the SDK does not model is preserved as an UnknownItem, so a response stays readable — and replays unchanged — after the API grows an item type.

See also

Inheritors

Properties

Link copied to clipboard
abstract val type: String

Raw type discriminator of the item.