Functions

Link copied to clipboard
abstract suspend fun assistant(id: AssistantId, requestOptions: RequestOptions? = null): Assistant?

Retrieves an assistant.

abstract suspend fun assistant(request: AssistantRequest, requestOptions: RequestOptions? = null): Assistant

Create an assistant with a model and instructions.

abstract suspend fun assistant(id: AssistantId, request: AssistantRequest, requestOptions: RequestOptions? = null): Assistant

Update an assistant.

Link copied to clipboard
abstract suspend fun assistants(limit: Int? = null, order: SortOrder? = null, after: AssistantId? = null, before: AssistantId? = null, requestOptions: RequestOptions? = null): List<Assistant>

Returns a list of assistants.

Link copied to clipboard
abstract suspend fun cancel(fineTuneId: FineTuneId): FineTune?
abstract suspend fun cancel(id: FineTuningId, requestOptions: RequestOptions? = null): FineTuningJob?

Immediately cancel a fine-tune job.

abstract suspend fun cancel(threadId: ThreadId, runId: RunId, requestOptions: RequestOptions? = null): Run

Cancels a run that is Status.InProgress.

abstract suspend fun cancel(vectorStoreId: VectorStoreId, batchId: BatchId, requestOptions: RequestOptions? = null): FilesBatch?

Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.

Link copied to clipboard
abstract suspend fun chatCompletion(request: ChatCompletionRequest, requestOptions: RequestOptions? = null): ChatCompletion

Creates a completion for the chat message.

Link copied to clipboard
abstract fun chatCompletions(request: ChatCompletionRequest, requestOptions: RequestOptions? = null): Flow<ChatCompletionChunk>

Stream variant of chatCompletion.

Link copied to clipboard
expect abstract fun close()
Link copied to clipboard
abstract suspend fun completion(request: CompletionRequest): TextCompletion

This is the main endpoint of the API. Returns the predicted completion for the given prompt, and can also return the probabilities of alternative tokens at each position if requested.

Link copied to clipboard
abstract fun completions(request: CompletionRequest): Flow<TextCompletion>

Stream variant of completion.

Link copied to clipboard
abstract suspend fun createRun(threadId: ThreadId, request: RunRequest, requestOptions: RequestOptions? = null): Run

Create a run.

Link copied to clipboard
abstract suspend fun createThreadRun(request: ThreadRunRequest, requestOptions: RequestOptions? = null): Run

Create a thread and run it in one request.

Link copied to clipboard
abstract suspend fun createVectorStore(request: VectorStoreRequest? = null, requestOptions: RequestOptions? = null): VectorStore

Create a new vector store.

Link copied to clipboard
abstract suspend fun createVectorStoreFile(id: VectorStoreId, request: VectorStoreFileRequest, requestOptions: RequestOptions? = null): VectorStoreFile

Create a vector store file by attaching a File to a vector store.

Link copied to clipboard
abstract suspend fun createVectorStoreFilesBatch(id: VectorStoreId, request: FileBatchRequest, requestOptions: RequestOptions? = null): FilesBatch

Create a batch of vector store files.

Link copied to clipboard
abstract suspend fun delete(id: AssistantId, requestOptions: RequestOptions? = null): Boolean

Delete an assistant.

abstract suspend fun delete(fileId: FileId, requestOptions: RequestOptions? = null): Boolean

Delete a file. Only owners of organizations can delete files currently.

abstract suspend fun delete(fineTuneModel: ModelId): Boolean

Delete a fine-tuned model. You must have the Owner role in your organization.

abstract suspend fun delete(id: ThreadId, requestOptions: RequestOptions? = null): Boolean

Delete a thread.

abstract suspend fun delete(id: VectorStoreId, requestOptions: RequestOptions? = null): Boolean

Delete a vector store.

abstract suspend fun delete(id: VectorStoreId, fileId: FileId, requestOptions: RequestOptions? = null): Boolean

Delete a vector store file. This will remove the file from the vector store, but the file itself will not be deleted. To delete the file, OpenAI.delete(fileId).

Link copied to clipboard
abstract suspend fun download(fileId: FileId, requestOptions: RequestOptions? = null): ByteArray

Returns the contents of the specified fileId.

Link copied to clipboard
abstract suspend fun edit(request: EditsRequest): Edit

Creates a new edit for the provided input, instruction, and parameters.

Link copied to clipboard
abstract suspend fun embeddings(request: EmbeddingRequest, requestOptions: RequestOptions? = null): EmbeddingResponse

Creates an embedding vector representing the input text.

Link copied to clipboard
abstract suspend fun file(fileId: FileId, requestOptions: RequestOptions? = null): File?

Returns information about a specific file.

abstract suspend fun file(request: FileUpload, requestOptions: RequestOptions? = null): File

Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB.

Link copied to clipboard
abstract suspend fun files(requestOptions: RequestOptions? = null): List<File>

Returns a list of files that belong to the user's organization.

Link copied to clipboard
abstract suspend fun fineTune(fineTuneId: FineTuneId): FineTune?

Gets info about to fine-tune job.

abstract suspend fun fineTune(request: FineTuneRequest): FineTune

Creates a job that fine-tunes a specified model from a given dataset.

Link copied to clipboard
abstract suspend fun fineTuneEvents(fineTuneId: FineTuneId): List<FineTuneEvent>

Get fine-grained status updates for fine-tune job.

Link copied to clipboard
abstract fun fineTuneEventsFlow(fineTuneId: FineTuneId): Flow<FineTuneEvent>

Get fine-grained status updates for fine-tune job.

Link copied to clipboard
abstract suspend fun fineTunes(): List<FineTune>

List your organization's fine-tuning jobs.

Link copied to clipboard
abstract suspend fun fineTuningEvents(id: FineTuningId, after: String? = null, limit: Int? = null, requestOptions: RequestOptions? = null): PaginatedList<FineTuningJobEvent>

Get status updates for a fine-tuning job.

Link copied to clipboard
abstract suspend fun fineTuningJob(id: FineTuningId, requestOptions: RequestOptions? = null): FineTuningJob?

Get info about a fine-tuning job.

abstract suspend fun fineTuningJob(request: FineTuningRequest, requestOptions: RequestOptions? = null): FineTuningJob

Creates a job that fine-tunes a specified model from a given dataset.

Link copied to clipboard
abstract suspend fun fineTuningJobs(after: String? = null, limit: Int? = null, requestOptions: RequestOptions? = null): List<FineTuningJob>

List your organization's fine-tuning jobs.

Link copied to clipboard
abstract suspend fun getRun(threadId: ThreadId, runId: RunId, requestOptions: RequestOptions? = null): Run

Retrieves a run.

Link copied to clipboard
abstract suspend fun imageJSON(creation: ImageCreation, requestOptions: RequestOptions? = null): List<ImageJSON>

Creates an image given a prompt. Get images as base 64 JSON.

abstract suspend fun imageJSON(edit: ImageEdit, requestOptions: RequestOptions? = null): List<ImageJSON>

Creates an edited or extended image given an original image and a prompt. Get images as base 64 JSON.

abstract suspend fun imageJSON(variation: ImageVariation, requestOptions: RequestOptions? = null): List<ImageJSON>

Creates a variation of a given image. Get images as base 64 JSON.

Link copied to clipboard
abstract suspend fun imageURL(creation: ImageCreation, requestOptions: RequestOptions? = null): List<ImageURL>

Creates an image given a prompt. Get images as URLs.

abstract suspend fun imageURL(edit: ImageEdit, requestOptions: RequestOptions? = null): List<ImageURL>

Creates an edited or extended image given an original image and a prompt. Get images as URLs.

abstract suspend fun imageURL(variation: ImageVariation, requestOptions: RequestOptions? = null): List<ImageURL>

Creates a variation of a given image. Get images as URLs.

Link copied to clipboard
abstract suspend fun message(threadId: ThreadId, messageId: MessageId, requestOptions: RequestOptions? = null): Message

Retrieve a message.

abstract suspend fun message(threadId: ThreadId, request: MessageRequest, requestOptions: RequestOptions? = null): Message

Create a message.

abstract suspend fun message(threadId: ThreadId, messageId: MessageId, metadata: Map<String, String>? = null, requestOptions: RequestOptions? = null): Message

Modify a message.

Link copied to clipboard
abstract suspend fun messages(threadId: ThreadId, limit: Int? = null, order: SortOrder? = null, after: MessageId? = null, before: MessageId? = null, requestOptions: RequestOptions? = null): List<Message>

Returns a list of messages for a given thread.

Link copied to clipboard
abstract suspend fun model(modelId: ModelId, requestOptions: RequestOptions? = null): Model

Retrieves a model instance, providing basic information about the model such as the owner and permission.

Link copied to clipboard
abstract suspend fun models(requestOptions: RequestOptions? = null): List<Model>

Lists the currently available models, and provides basic information about each one such as the owner and availability.

Link copied to clipboard
abstract suspend fun moderations(request: ModerationRequest, requestOptions: RequestOptions? = null): TextModeration

Classifies if a text violates OpenAI's Content Policy.

Link copied to clipboard
abstract suspend fun runs(threadId: ThreadId, limit: Int? = null, order: SortOrder? = null, after: RunId? = null, before: RunId? = null, requestOptions: RequestOptions? = null): List<Run>

Returns a list of runs belonging to a thread.

Link copied to clipboard
abstract suspend fun runStep(threadId: ThreadId, runId: RunId, stepId: RunStepId, requestOptions: RequestOptions? = null): RunStep

Retrieves a run step.

Link copied to clipboard
abstract suspend fun runSteps(threadId: ThreadId, runId: RunId, limit: Int? = null, order: SortOrder? = null, after: RunStepId? = null, before: RunStepId? = null, requestOptions: RequestOptions? = null): List<RunStep>

Retrieves a run step.

Link copied to clipboard
abstract suspend fun speech(request: SpeechRequest, requestOptions: RequestOptions? = null): ByteArray

Generates audio from the input text.

Link copied to clipboard
abstract suspend fun submitToolOutput(threadId: ThreadId, runId: RunId, output: List<ToolOutput>, requestOptions: RequestOptions? = null): Run

When a run has the status: Status.RequiresAction and required action is RequiredAction.SubmitToolOutputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.

Link copied to clipboard
abstract suspend fun thread(id: ThreadId, requestOptions: RequestOptions? = null): Thread?

Retrieve a thread.

abstract suspend fun thread(request: ThreadRequest? = null, requestOptions: RequestOptions? = null): Thread

Create a thread.

abstract suspend fun thread(id: ThreadId, metadata: Map<String, String>, requestOptions: RequestOptions? = null): Thread

Modify a thread.

Link copied to clipboard
abstract suspend fun transcription(request: TranscriptionRequest, requestOptions: RequestOptions? = null): Transcription

Transcribes audio into the input language.

Link copied to clipboard
abstract suspend fun translation(request: TranslationRequest, requestOptions: RequestOptions? = null): Translation

Translates audio into English.

Link copied to clipboard
abstract suspend fun updateRun(threadId: ThreadId, runId: RunId, metadata: Map<String, String>? = null, requestOptions: RequestOptions? = null): Run

Modifies a run.

Link copied to clipboard
abstract suspend fun updateVectorStore(id: VectorStoreId, request: VectorStoreRequest, requestOptions: RequestOptions? = null): VectorStore

Update a vector store.

Link copied to clipboard
abstract suspend fun vectorStore(id: VectorStoreId, requestOptions: RequestOptions? = null): VectorStore?

Retrieve a vector store.

Link copied to clipboard
abstract suspend fun vectorStoreFileBatch(vectorStoreId: VectorStoreId, batchId: BatchId, requestOptions: RequestOptions? = null): FilesBatch?

Retrieves a vector store file batch.

Link copied to clipboard
abstract suspend fun vectorStoreFiles(id: VectorStoreId, limit: Int? = null, order: SortOrder? = null, after: VectorStoreId? = null, before: VectorStoreId? = null, filter: Status? = null, requestOptions: RequestOptions? = null): List<VectorStoreFile>

Returns a list of vector store files.

Link copied to clipboard
abstract suspend fun vectorStoreFilesBatches(vectorStoreId: VectorStoreId, batchId: BatchId, limit: Int? = null, order: SortOrder? = null, after: VectorStoreId? = null, before: VectorStoreId? = null, filter: Status? = null, requestOptions: RequestOptions? = null): List<VectorStoreFile>

Returns a list of vector store files in a batch.

Link copied to clipboard
abstract suspend fun vectorStores(limit: Int? = null, order: SortOrder? = null, after: VectorStoreId? = null, before: VectorStoreId? = null, requestOptions: RequestOptions? = null): List<VectorStore>

List all vector stores.