Package-level declarations

Types

Link copied to clipboard
interface Assistants

Build assistants that can call models and use tools to perform tasks.

Link copied to clipboard
interface Audio

Learn how to turn audio into text.

Link copied to clipboard
interface Batch

Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours for a 50% discount.

Link copied to clipboard
interface Chat

Given a chat conversation, the model will return a chat completion response.

Link copied to clipboard
interface Completions

Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.

Link copied to clipboard
interface Containers

Manages hosted containers and their files. Container creation can incur hosted resource charges. Default implementations preserve source compatibility for custom clients.

Link copied to clipboard

Checks image/audio uploads for supported OpenAI provenance signals.

Link copied to clipboard
interface Conversations

Manage persisted conversations and their items. Deleting a conversation does not delete its items.

Link copied to clipboard
interface Decisions

Evaluates evidence using predicate, choice and score questions.

Link copied to clipboard
interface Edits

Given a prompt and an instruction, the model will return an edited version of the prompt.

Link copied to clipboard
interface Embeddings

Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.

Link copied to clipboard
interface Files

Files contain data for Responses, vector stores, batch requests, and fine-tuning.

Link copied to clipboard
interface FineTunes

Manage fine-tuning jobs to tailor a model to your specific training data.

Link copied to clipboard
interface FineTuning

Manage fine-tuning jobs to tailor a model to your specific training data.

Link copied to clipboard

Shares checkpoint models between projects. All operations require an Admin API key.

Link copied to clipboard
interface Images

Given a prompt and/or an input image, the model will generate a new image.

Link copied to clipboard
interface Live

Live media-session lifecycle and scoped server WebSockets. Default methods preserve custom-client source compatibility.

Link copied to clipboard
interface LiveConnection

Scoped Live primary, sideband or fork WebSocket. Device audio and media processing belong to the caller.

Link copied to clipboard
class LoggingConfig(val logLevel: LogLevel = LogLevel.Headers, val logger: Logger = Logger.Simple, val sanitize: Boolean = true)

Defines the configuration parameters for logging.

Link copied to clipboard
interface Messages

Create messages within threads

Link copied to clipboard
interface Models

List and describe the various models available in the API. You can refer to the Models documentation to understand what models are available and the differences between them.

Link copied to clipboard
interface Moderations

Classifies text and images against OpenAI's content policy.

Link copied to clipboard

Organization management client. Use an Admin API key, separately from application credentials.

Link copied to clipboard
class OpenAIConfig(val token: String, val logging: LoggingConfig = LoggingConfig(), val timeout: Timeout = Timeout(socket = 30.seconds), val organization: String? = null, val headers: Map<String, String> = emptyMap(), val host: OpenAIHost = OpenAIHost.OpenAI, val proxy: ProxyConfig? = null, val retry: RetryStrategy = RetryStrategy(), val engine: HttpClientEngine? = null, val httpClientConfig: HttpClientConfig<*>.() -> Unit = {})

OpenAI client configuration.

Link copied to clipboard
class OpenAIHost(val baseUrl: String, val queryParams: Map<String, String> = emptyMap())

A class to configure the OpenAI host. It provides a mechanism to customize the base URL and additional query parameters used in OpenAI API requests.

Link copied to clipboard

Organization identity and project management using an Admin API key.

Link copied to clipboard

Organization governance operations requiring an Admin API credential. Default methods support custom clients.

Link copied to clipboard

Manages organization and project hard spend limits and notification alerts using an Admin API key. Default operations throw UnsupportedOperationException so custom clients can omit this capability.

Link copied to clipboard

Reads organization usage and cost reports using an Admin API key.

Link copied to clipboard
sealed interface ProxyConfig

Proxy configuration.

Link copied to clipboard
interface Realtime

Realtime credentials, call signaling and scoped server WebSocket connections.

Link copied to clipboard

Scoped bidirectional GA Realtime connection. Audio capture/playback and media encoding belong to the caller.

Link copied to clipboard

A scoped Responses WebSocket. Keep one event collector active while sending successive turns.

Link copied to clipboard
interface Responses

Create and manage model responses.

Link copied to clipboard
class RetryStrategy(val maxRetries: Int = 3, val base: Double = 2.0, val maxDelay: Duration = 60.seconds)

Specifies the retry strategy

Link copied to clipboard
interface Runs

Represents an execution run on a thread.

Link copied to clipboard
interface Safety

Retrieves existing safety resources authorized for the supplied credential.

Link copied to clipboard
interface Skills

Manages hosted skills and immutable versions without executing their contents. Default implementations preserve source compatibility for custom clients.

Link copied to clipboard
interface Threads

Create threads that assistants can interact with.

Link copied to clipboard
interface Uploads

Upload files in parts, then assemble them into a regular file. Default methods throw UnsupportedOperationException so custom OpenAI implementations remain source compatible. Clients created by the SDK implement all operations.

Link copied to clipboard
interface VectorStores

Vector stores are used to store files for use by the file_search tool.

Link copied to clipboard
interface VoiceManagement

Manages saved custom voices and consent recordings in the authenticated project. Default operations throw UnsupportedOperationException, allowing existing custom clients to omit this capability.

Link copied to clipboard
interface Webhooks

Manages webhook endpoints in the authenticated project.

Functions

Link copied to clipboard
fun HttpClientConfig<*>.onResponseMetadata(observer: (ResponseMetadata) -> Unit)

Observes HTTP status and response headers for every response received by this client, including error responses, retries, and redirects, before decoding or streaming the body. A transport failure or cancellation before receiving a response does not invoke observer.

Link copied to clipboard
fun OpenAI(config: OpenAIConfig): OpenAI
fun OpenAI(token: String, logging: LoggingConfig = LoggingConfig(), timeout: Timeout = Timeout(socket = 30.seconds), organization: String? = null, headers: Map<String, String> = emptyMap(), host: OpenAIHost = OpenAIHost.OpenAI, proxy: ProxyConfig? = null, retry: RetryStrategy = RetryStrategy(), httpClientConfig: HttpClientConfig<*>.() -> Unit = {}): OpenAI

Creates an instance of OpenAI.

Link copied to clipboard

Creates an administration client; OpenAIConfig.token must authorize the requested admin operations.

Creates an administration client with the supplied Admin API key.