Package-level declarations

Types

Link copied to clipboard
class ContentPartAddedEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val contentIndex: Int, val part: ResponseContentPart) : ContentPartEvent

A new content part has started inside an output item.

Link copied to clipboard
class ContentPartDoneEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val contentIndex: Int, val part: ResponseContentPart) : ContentPartEvent

A content part is complete; part holds its final form.

Link copied to clipboard

An event marking the start or the end of one content part inside an output item.

Link copied to clipboard
@Serializable
class CustomTool(val name: String) : ResponseTool

A free-form tool that takes raw text instead of JSON arguments.

Link copied to clipboard
class CustomToolCallInputDeltaEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val delta: String) : ToolInputDeltaEvent

A fragment of the free-form input the model is generating for a CustomToolCallItem.

Link copied to clipboard
class CustomToolCallInputDoneEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val input: String) : ToolInputDoneEvent

The finished input of a custom tool call.

Link copied to clipboard
@Serializable
class CustomToolCallItem(val callId: String, val name: String, val input: String, val id: String? = null, val status: ResponseStatus? = null) : ResponseItem

A call to the apply_patch custom tool, which takes free-form input instead of JSON arguments.

Link copied to clipboard
@Serializable
class CustomToolCallOutputItem(val callId: String, val output: ResponseContent) : ResponseItem

The result of running a CustomToolCallItem.

Link copied to clipboard
class FunctionCallArgumentsDeltaEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val delta: String) : ToolInputDeltaEvent

A fragment of the JSON arguments the model is generating for a FunctionCallItem.

Link copied to clipboard
class FunctionCallArgumentsDoneEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val arguments: String) : ToolInputDoneEvent

The finished JSON arguments of a function call.

Link copied to clipboard
@Serializable
class FunctionCallItem(val callId: String, val name: String, val arguments: String, val id: String? = null, val status: ResponseStatus? = null) : ResponseItem

A function the model asked to call.

Link copied to clipboard
@Serializable
class FunctionCallOutputItem(val callId: String, val output: ResponseContent) : ResponseItem

The result of running a function the model called.

Link copied to clipboard
@Serializable
class FunctionTool(val name: String, val description: String? = null, val parameters: JsonObject? = null) : ResponseTool

A function the model may call, described by its JSON Schema.

Link copied to clipboard
@Serializable
class IncompleteDetails(val reason: IncompleteReason? = null)

Why a ResponseStatus.INCOMPLETE response stopped short.

Link copied to clipboard
@Serializable
value class IncompleteReason(val value: String)

Reason a response was truncated, serialized as the raw value the API sends.

Link copied to clipboard
@Serializable
class InputImagePart(val imageUrl: String? = null, val fileId: String? = null, val detail: ImageDetail? = null) : ResponseContentPart

Image sent to the model, as input_image.

Link copied to clipboard
@Serializable
class InputTextPart(val text: String) : TextContentPart

Text sent to the model, as input_text.

Link copied to clipboard
@Serializable
class InputTokensDetails(val cachedTokens: Int? = null)

Breakdown of the input tokens counted in ResponseUsage.inputTokens.

Link copied to clipboard
@Serializable
class MessageItem(val role: ResponseRole, val content: ResponseContent?, val id: String? = null, val status: ResponseStatus? = null) : ResponseItem

A message turn: text, or multimodal parts, attributed to a ResponseRole.

Link copied to clipboard
@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.

Link copied to clipboard

Forces the model to call one specific tool.

Link copied to clipboard
class OutputItemAddedEvent(val sequenceNumber: Int, val outputIndex: Int, val item: ResponseItem) : OutputItemEvent

A new output item — reasoning, message, tool call — has started.

Link copied to clipboard
class OutputItemDoneEvent(val sequenceNumber: Int, val outputIndex: Int, val item: ResponseItem) : OutputItemEvent

An output item is complete; item holds its final form.

Link copied to clipboard

An event marking the start or the end of one item of ModelResponse.output.

Link copied to clipboard
class OutputTextDeltaEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val contentIndex: Int, val delta: String) : TextDeltaEvent

A fragment of the visible answer. This is the event most callers print as it arrives.

Link copied to clipboard
class OutputTextDoneEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val contentIndex: Int, val text: String) : TextDoneEvent

The visible answer of one content part, complete.

Link copied to clipboard
@Serializable
class OutputTextPart(val text: String) : TextContentPart

Text produced by the model, as output_text.

Link copied to clipboard
@Serializable
class OutputTokensDetails(val reasoningTokens: Int? = null)

Breakdown of the output tokens counted in ResponseUsage.outputTokens.

Link copied to clipboard
@Serializable
class ReasoningConfig(val effort: ReasoningEffort? = null)

Thinking-mode configuration of a Responses API request.

Link copied to clipboard
@Serializable
class ReasoningItem(val content: List<ResponseContentPart> = emptyList(), val id: String? = null, val status: ResponseStatus? = null) : ResponseItem

The chain-of-thought a thinking model produced before its answer.

Link copied to clipboard
class ReasoningTextDeltaEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val contentIndex: Int, val delta: String) : TextDeltaEvent

A fragment of the chain-of-thought a thinking model produces before its answer.

Link copied to clipboard
class ReasoningTextDoneEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int, val contentIndex: Int, val text: String) : TextDoneEvent

The chain-of-thought of one content part, complete.

Link copied to clipboard
@Serializable
class ReasoningTextPart(val text: String) : TextContentPart

Chain-of-thought produced by the model in thinking mode, as reasoning_text.

Link copied to clipboard
class ResponseCompletedEvent(val sequenceNumber: Int, val response: ModelResponse) : ResponseSnapshotEvent

Terminal event of a response that finished normally, carrying its output and usage.

Link copied to clipboard
@Serializable(with = ResponseContentSerializer::class)
sealed interface ResponseContent

The two shapes a content or output field takes on the wire: a bare string, or an array of ResponseContentParts.

Link copied to clipboard
@Serializable(with = ResponseContentPartSerializer::class)
sealed interface ResponseContentPart

One element of the content array of a ResponseItem.

Link copied to clipboard
class ResponseCreatedEvent(val sequenceNumber: Int, val response: ModelResponse) : ResponseSnapshotEvent

The first event of the stream: the response exists and generation has started.

Link copied to clipboard
@Serializable
class ResponseError(val code: String? = null, val message: String? = null)

What went wrong on a ResponseStatus.FAILED response.

Link copied to clipboard
class ResponseFailedEvent(val sequenceNumber: Int, val response: ModelResponse) : ResponseSnapshotEvent

Terminal event of a response that failed; see ModelResponse.error.

Link copied to clipboard
class ResponseIncompleteEvent(val sequenceNumber: Int, val response: ModelResponse) : ResponseSnapshotEvent

Terminal event of a response that was cut short — by max_output_tokens or the content filter; see ModelResponse.incompleteDetails.

Link copied to clipboard
class ResponseInProgressEvent(val sequenceNumber: Int, val response: ModelResponse) : ResponseSnapshotEvent

Progress ping: the response is still being generated.

Link copied to clipboard
@Serializable(with = ResponseInputSerializer::class)
sealed interface ResponseInput

The two shapes the input of a ResponseRequest takes on the wire: a bare string, treated by the API as a single user message, or an array of ResponseItems.

Link copied to clipboard
@Serializable(with = ResponseItemSerializer::class)
sealed interface ResponseItem

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

Link copied to clipboard

Everything about a Responses API call except the conversation itself.

Link copied to clipboard
@Serializable
class ResponseRequest(val model: ChatModel, val input: ResponseInput? = null, val instructions: String? = null, val reasoning: ReasoningConfig? = null, val maxOutputTokens: Int? = null, val stream: Boolean? = null, val temperature: Double? = null, val topP: Double? = null, val text: TextConfig? = null, val tools: List<ResponseTool>? = null, val toolChoice: ResponseToolChoice? = null, val topLogprobs: Int? = null, val user: String? = null)

A request to the Responses API.

Link copied to clipboard
@Serializable
value class ResponseRole(val value: String)

Author of a MessageItem.

Link copied to clipboard

An event carrying a snapshot of the whole response.

Link copied to clipboard
@Serializable
value class ResponseStatus(val value: String)

State of a ModelResponse or of a single ResponseItem, serialized as the raw value the API sends.

Link copied to clipboard
@Serializable(with = ResponseStreamEventSerializer::class)
sealed interface ResponseStreamEvent

One semantic server-sent event of a streamed Responses API call.

Link copied to clipboard
@Serializable(with = ResponseToolSerializer::class)
sealed interface ResponseTool

A tool the model may use while producing a response.

Link copied to clipboard
@Serializable(with = ResponseToolChoiceSerializer::class)
sealed interface ResponseToolChoice

Controls which tool, if any, the model calls.

Link copied to clipboard

Coarse tool-selection strategy.

Link copied to clipboard
@Serializable
class ResponseUsage(val inputTokens: Int, val inputTokensDetails: InputTokensDetails? = null, val outputTokens: Int, val outputTokensDetails: OutputTokensDetails? = null, val totalTokens: Int)

Token usage statistics of a ModelResponse.

Link copied to clipboard
@Serializable
class TextConfig(val format: TextFormat)

Shape of the text the model must produce.

Link copied to clipboard

Base of the three content parts that carry nothing but text, so they can be matched at once:

Link copied to clipboard

An incremental piece of text produced inside a content part.

Link copied to clipboard

The complete text of a content part, sent once its deltas are done.

Link copied to clipboard
@Serializable
class TextFormat

Wire form of TextConfig.format. Build it through the TextConfig factories rather than directly.

Link copied to clipboard

An incremental piece of the input the model is generating for a tool call.

Link copied to clipboard

The complete input of a tool call, sent once its deltas are done.

Link copied to clipboard
class UnknownItem(val type: String, val raw: JsonObject) : ResponseItem

An item whose type this version of the SDK does not model.

Link copied to clipboard
class UnknownResponseContentPart(val type: String, val raw: JsonObject) : ResponseContentPart

A content part whose type this version of the SDK does not model.

Link copied to clipboard
class UnknownResponseStreamEvent(val type: String, val sequenceNumber: Int, val raw: JsonObject) : ResponseStreamEvent

An event this version of the SDK cannot map: an unknown type, or a known one whose payload does not fit the expected shape.

Link copied to clipboard
class UnknownTool(val type: String, val raw: JsonObject) : ResponseTool

A tool whose type this version of the SDK does not model, kept verbatim so it round-trips.

Link copied to clipboard
class WebSearchCallCompletedEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int) : WebSearchCallEvent

The web search has finished and its results are feeding back into the model.

Link copied to clipboard

A status update of a web search the API is running server-side.

Link copied to clipboard
class WebSearchCallInProgressEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int) : WebSearchCallEvent

A web search call has been created and is about to run.

Link copied to clipboard
@Serializable
class WebSearchCallItem(val action: JsonObject? = null, val id: String? = null, val status: ResponseStatus? = null) : ResponseItem

A web search the API ran on its own, server side.

Link copied to clipboard
class WebSearchCallSearchingEvent(val sequenceNumber: Int, val itemId: String, val outputIndex: Int) : WebSearchCallEvent

The web search is running.

Link copied to clipboard

The built-in web search, executed on the API's side.

Functions

Link copied to clipboard
fun FunctionCallItem.argumentsAsJsonOrNull(json: Json = Json): JsonObject?

Parses FunctionCallItem.arguments into a JsonObject, or returns null when the model produced malformed JSON or a JSON value that is not an object.

Link copied to clipboard

Creates Responses API parameters using a builder.

Link copied to clipboard

Creates streaming Responses API parameters using a builder.