Package-level declarations

Types

Link copied to clipboard
@Serializable
data class ApproximateLocation(val city: String? = null, val country: String? = null, val region: String? = null, val timezone: String? = null)

Approximate location details.

Link copied to clipboard

Assistant message builder.

Link copied to clipboard
@Serializable
data class ChatAllowedTool(val type: String, val function: FunctionToolChoice? = null, val custom: FunctionToolChoice? = null)

A function or custom tool reference.

Link copied to clipboard
@Serializable
data class ChatAllowedTools(val mode: String, val tools: List<ChatAllowedTool>)

Allowed subset of tools.

Link copied to clipboard
@Serializable(with = ChatAnnotationSerializer::class)
data class ChatAnnotation(val type: String, val url: String? = null, val title: String? = null, val startIndex: Int? = null, val endIndex: Int? = null, val text: String? = null)

Annotation for assistant message content.

Link copied to clipboard
@Serializable
data class ChatAudio(val id: String, val data: String? = null, val transcript: String? = null, val expiresAt: Long? = null)

Generated audio, or a reference to a prior assistant audio output.

Link copied to clipboard
@Serializable
data class ChatAudioConfig(val format: String, val voice: String)

Audio output configuration.

Link copied to clipboard
@Serializable
data class ChatChoice(val index: Int, val message: ChatMessage, val finishReason: FinishReason? = null, val logprobs: Logprobs? = null)

A completion generated by OpenAI.

Link copied to clipboard
@Serializable
data class ChatChunk(val index: Int, val delta: ChatDelta? = null, val contentFilterOffsets: ContentFilterOffsets? = null, val contentFilterResults: ContentFilterResults? = null, val finishReason: FinishReason? = null)

A completion generated by OpenAI.

Link copied to clipboard
@Serializable
data class ChatCompletion(val id: String, val created: Long, val model: ModelId, val choices: List<ChatChoice>, val usage: Usage? = null, val systemFingerprint: String? = null)

An object containing a response from the chat completion api.

Link copied to clipboard
@Serializable
data class ChatCompletionChunk(val id: String, val created: Long, val model: ModelId, val choices: List<ChatChunk>, val usage: Usage? = null, val systemFingerprint: String? = null)

An object containing a response from the chat stream completion api.

Link copied to clipboard
@Serializable
data class ChatCompletionFunction(val name: String, val description: String? = null, val parameters: Parameters)
Link copied to clipboard
Link copied to clipboard
data class ChatCompletionListQuery(val after: String? = null, val limit: Int? = null, val metadata: Map<String, String>? = null, val model: ModelId? = null, val order: SortOrder? = null)

Filters for listing stored Chat Completions.

Link copied to clipboard
@Serializable
data class ChatCompletionOptions(val messages: List<ChatInputMessage>? = null, val tools: List<ChatTool>? = null, val toolChoice: ChatToolSelection? = null, val metadata: Map<String, String>? = null, val parallelToolCalls: Boolean? = null, val serviceTier: String? = null, val safetyIdentifier: String? = null, val promptCacheKey: String? = null, val promptCacheOptions: ChatPromptCacheOptions? = null, val verbosity: String? = null, val moderation: ChatModeration? = null, val modalities: List<String>? = null, val audio: ChatAudioConfig? = null, val prediction: ChatPrediction? = null, val streamOptions: ChatStreamOptions? = null)

Advanced fields whose types differ from the original Chat request contract.

Link copied to clipboard
@Serializable
data class ChatCompletionRequest(val model: ModelId, val messages: List<ChatMessage>, val reasoningEffort: Effort? = null, val temperature: Double? = null, val topP: Double? = null, val n: Int? = null, val stop: List<String>? = null, val store: Boolean? = null, val maxTokens: Int? = null, val maxCompletionTokens: Int? = null, val presencePenalty: Double? = null, val frequencyPenalty: Double? = null, val logitBias: Map<String, Int>? = null, val user: String? = null, val functions: List<ChatCompletionFunction>? = null, val functionCall: FunctionMode? = null, val responseFormat: ChatResponseFormat? = null, val tools: List<Tool>? = null, val toolChoice: ToolChoice? = null, val webSearchOptions: WebSearchOptions? = null, val seed: Int? = null, val logprobs: Boolean? = null, val topLogprobs: Int? = null, val instanceId: String? = null, val streamOptions: StreamOptions? = null)

Creates a completion for the chat message.

Link copied to clipboard

Creates a completion for the chat message.

Link copied to clipboard
@Serializable
data class ChatCompletionResult(val id: String, val created: Long, val model: ModelId, val choices: List<ChatResultChoice>, val usage: ChatUsage? = null, val serviceTier: String? = null, val systemFingerprint: String? = null, val metadata: Map<String, String>? = null)

Completion result supporting custom calls without extending legacy sealed types.

Link copied to clipboard
@Serializable
data class ChatCompletionUpdate(val metadata: Map<String, String>)

Metadata update for an existing stored completion.

Link copied to clipboard
@Serializable
data class ChatCustomCall(val name: String? = null, val input: String? = null)

Name and free-form input of a custom call.

Link copied to clipboard
@Serializable
data class ChatDelta(val role: ChatRole? = null, val content: String? = null, val functionCall: FunctionCall? = null, val toolCalls: List<ToolCallChunk>? = null, val toolCallId: ToolId? = null, val reasoningContent: String? = null)

Generated chat message.

Link copied to clipboard
@Serializable
data class ChatFunctionDefinition(val name: String, val parameters: Parameters? = null, val description: String? = null, val strict: Boolean? = null)

Rich function definition for advanced Chat requests.

Link copied to clipboard
@Serializable
data class ChatFunctionTool(val function: ChatFunctionDefinition, val type: String = "function") : ChatTool

Function declaration supporting strict schema enforcement without changing FunctionTool.

Link copied to clipboard
@Serializable
data class ChatInputAudio(val data: String, val format: String)

Encoded audio input.

Link copied to clipboard
@Serializable(with = ChatInputContentSerializer::class)
sealed interface ChatInputContent

Typed content for advanced Chat inputs.

Link copied to clipboard
@Serializable
data class ChatInputFile(val fileId: String? = null, val fileData: String? = null, val filename: String? = null)

Uploaded file or inline file data.

Link copied to clipboard
@Serializable
data class ChatInputMessage(val role: Role, val content: ChatInputContent? = null, val name: String? = null, val toolCalls: List<ChatResultToolCall>? = null, val toolCallId: String? = null, val audio: ChatAudio? = null, val refusal: String? = null, val functionCall: FunctionCall? = null, val reasoningContent: String? = null)

Advanced input message supporting multimodal content and custom tool calls.

Link copied to clipboard
@Serializable
sealed interface ChatInputPart

Independent multimodal input part hierarchy.

Link copied to clipboard
@Serializable
value class ChatInputParts(val value: List<ChatInputPart>) : ChatInputContent

Multimodal content parts.

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

Plain text input.

Link copied to clipboard
@Serializable
data class ChatMessage(val role: ChatRole, val messageContent: Content? = null, val name: String? = null, val functionCall: FunctionCall? = null, val toolCalls: List<ToolCall>? = null, val toolCallId: ToolId? = null, val contentFilterResults: List<ContentFilterResults>? = null, val contentFilterOffsets: List<ContentFilterOffsets>? = null, val annotations: List<ChatAnnotation>? = null, val reasoningContent: String? = null)

The messages to generate chat completions for.

Link copied to clipboard

Builder of ChatMessageBuilder instances.

Link copied to clipboard

Creates a list of ChatMessage.

Link copied to clipboard
@Serializable
data class ChatModeration(val model: String, val policy: ChatModerationPolicy? = null)

Moderation configuration for chat inputs and outputs.

Link copied to clipboard
@Serializable
data class ChatModerationMode(val mode: String)

Moderation behavior: score content or block policy violations.

Link copied to clipboard
@Serializable
data class ChatModerationPolicy(val input: ChatModerationMode? = null, val output: ChatModerationMode? = null)

Separate moderation policies for input and output.

Link copied to clipboard
@Serializable
data class ChatPrediction(val content: Content, val type: String = "content")

Predicted output content used to accelerate responses with a known prefix.

Link copied to clipboard
@Serializable
data class ChatPromptCacheOptions(val mode: String? = null, val ttl: String? = null)

Prompt caching mode and minimum lifetime; supported values depend on the model.

Link copied to clipboard
data class ChatResponseFormat(val type: String, val jsonSchema: JsonSchema? = null)

An object specifying the format that the model must output.

Link copied to clipboard
@Serializable
data class ChatResultAnnotation(val type: String, val urlCitation: UrlCitation? = null, val url: String? = null, val title: String? = null, val startIndex: Int? = null, val endIndex: Int? = null, val text: String? = null, val fileId: String? = null, val filename: String? = null, val index: Int? = null, val containerId: String? = null)

Output citation used by rich Chat result messages.

Link copied to clipboard
@Serializable
data class ChatResultChoice(val index: Int, val message: ChatResultMessage? = null, val delta: ChatResultMessage? = null, val finishReason: FinishReason? = null, val logprobs: Logprobs? = null)

Generated choice, or a streamed choice delta.

Link copied to clipboard
@Serializable
data class ChatResultMessage(val id: String? = null, val name: String? = null, val contentParts: List<ChatInputPart>? = null, val role: Role? = null, val content: String? = null, val toolCalls: List<ChatResultToolCall>? = null, val annotations: List<ChatResultAnnotation>? = null, val audio: ChatAudio? = null, val refusal: String? = null, val functionCall: FunctionCall? = null, val reasoningContent: String? = null)

Complete or incremental assistant message with custom tool calls.

Link copied to clipboard
@Serializable
data class ChatResultToolCall(val id: String? = null, val type: String? = null, val index: Int? = null, val function: FunctionCall? = null, val custom: ChatCustomCall? = null)

Function/custom call; optional fields support incremental streaming updates.

Link copied to clipboard
typealias ChatRole = Role

The role of the author of a message.

Link copied to clipboard
@Serializable
data class ChatStreamOptions(val includeUsage: Boolean? = null, val includeObfuscation: Boolean? = null)

Streaming controls for advanced Chat requests.

Link copied to clipboard
@Serializable(with = ChatToolSerializer::class)
sealed interface ChatTool

Tool accepted by Chat Completions, either a function or custom text tool.

Link copied to clipboard
@Serializable
data class ChatToolSelection(val type: String, val custom: FunctionToolChoice? = null, val allowedTools: ChatAllowedTools? = null)

Select a custom tool or an allowed tool subset.

Link copied to clipboard
@Serializable
data class ChatUsage(val promptTokens: Int? = null, val completionTokens: Int? = null, val totalTokens: Int? = null, val promptTokensDetails: PromptTokensDetails? = null, val completionTokensDetails: CompletionTokensDetails? = null)

Usage details returned by advanced Chat operations.

Link copied to clipboard
@Serializable(with = ContentSerializer::class)
sealed interface Content

The contents of the chat message.

Link copied to clipboard
@Serializable
data class ContentFilterOffsets(val checkOffset: Int?, val startOffset: Int?, val endOffset: Int?)
Link copied to clipboard
@Serializable
data class ContentFilterResult(val filtered: Boolean, val severity: String)
Link copied to clipboard
@Serializable
data class ContentFilterResults(val hate: ContentFilterResult? = null, val selfHarm: ContentFilterResult? = null, val sexual: ContentFilterResult? = null, val violence: ContentFilterResult? = null, val jailbreak: ContentFilterResult? = null, val profanity: ContentFilterResult? = null)
Link copied to clipboard
@Serializable
sealed interface ContentPart

Represents a chat message part.

Link copied to clipboard
Link copied to clipboard
@Serializable
data class CustomTool(val custom: CustomToolDefinition, val type: String = "custom") : ChatTool

A tool accepting free-form or grammar-constrained text.

Link copied to clipboard
@Serializable
data class CustomToolDefinition(val name: String, val description: String? = null, val format: CustomToolFormat? = null)

Custom tool declaration.

Link copied to clipboard
@Serializable
data class CustomToolFormat(val type: String, val grammar: CustomToolGrammar? = null)

Custom tool input format: text, or grammar with a definition and syntax.

Link copied to clipboard
@Serializable
data class CustomToolGrammar(val definition: String, val syntax: String)

Grammar accepted by a custom tool.

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

Reasoning Effort.

Link copied to clipboard
@Serializable
data class FunctionCall(val nameOrNull: String? = null, val argumentsOrNull: String? = null)

Represents a function invocation with its name and serialized arguments as generated by the model.

Link copied to clipboard
@Serializable(with = FunctionModeSerializer::class)
sealed interface FunctionMode

This interface determines how the model handles function calls.

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

A description of what the function does, used by the model to choose when and how to call the function.

Link copied to clipboard

Tool call builder.

Link copied to clipboard
@Serializable
data class FunctionToolChoice(val name: String)

Represents the function to call by the model.

Link copied to clipboard
@Serializable
@SerialName(value = "image_url")
data class ImagePart(val imageUrl: ImagePart.ImageURL) : ContentPart

Image content part.

Link copied to clipboard
@Serializable
data class JsonSchema(val name: String? = null, val schema: JsonObject, val strict: Boolean? = null)

Specification for JSON schema response format

Link copied to clipboard
@Serializable
value class ListContent(val content: List<ContentPart>) : Content

The chat message content as a list of content parts.

Link copied to clipboard
@Serializable
data class Logprobs(val content: List<LogprobsContent>? = null)

An object containing log probability information for the choice.

Link copied to clipboard
@Serializable
data class LogprobsContent(val token: String, val logprob: Double, val bytes: List<Int>? = null, val topLogprobs: List<TopLogprob>)

An object containing logprobs for a single token

Link copied to clipboard

Represents parameters that a function accepts, described as a JSON Schema object.

Link copied to clipboard
@Serializable
data class PromptCacheBreakpoint(val mode: String = "explicit", val ttl: String? = null)

Explicit cache boundary on an input content part.

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

Search context size setting for web search.

Link copied to clipboard
@Serializable
data class StreamOptions(val includeUsage: Boolean? = null)

Options for streaming response.

Link copied to clipboard
Link copied to clipboard

System message builder.

Link copied to clipboard
@Serializable
value class TextContent(val content: String) : Content

The chat message content as text.

Link copied to clipboard
@Serializable
@SerialName(value = "text")
data class TextPart(val text: String) : ContentPart

Text content part.

Link copied to clipboard
@Serializable
data class Tool(val type: ToolType, val function: FunctionTool) : ChatTool

A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.

Link copied to clipboard

Creates a list of Tool.

Link copied to clipboard
@Serializable
sealed interface ToolCall

Details of the tool call.

Link copied to clipboard
@Serializable
data class ToolCallChunk(val index: Int, val type: String? = null, val id: ToolId? = null, val function: FunctionCall? = null)

Details of the tool call chunk.

Link copied to clipboard

List of tool calls builder.

Link copied to clipboard
@Serializable(with = ToolChoiceSerializer::class)
sealed interface ToolChoice

Controls which (if any) function is called by the model.

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

The ID of the tool call.

Link copied to clipboard

Tool message builder.

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

The type of the tool.

Link copied to clipboard
@Serializable
data class TopLogprob(val token: String, val logprob: Double, val bytes: List<Int>? = null)

An object containing a token and their log probability.

Link copied to clipboard
@Serializable
data class UrlCitation(val url: String, val title: String, val startIndex: Int, val endIndex: Int)

Nested Chat URL citation.

Link copied to clipboard
@Serializable
data class UserLocation(val type: String = "approximate", val approximate: ApproximateLocation? = null)

Location hint used by web search.

Link copied to clipboard

User message builder.

Link copied to clipboard
@Serializable
data class WebSearchOptions(val searchContextSize: SearchContextSize? = null, val userLocation: UserLocation? = null)

Configuration for web search in chat completions.

Functions

Link copied to clipboard

Assistant chat message.

Link copied to clipboard

The function to generate chat completion function instances.

Link copied to clipboard

The messages to generate chat completions for.

Link copied to clipboard

The messages to generate chat completions for.

Link copied to clipboard

Tool: function call.

Link copied to clipboard

Create a new StreamOptions instance.

Link copied to clipboard

System chat message.

Link copied to clipboard

Tool chat message.

Link copied to clipboard

User chat message.