Conversations

interface Conversations

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

Default implementations throw UnsupportedOperationException so existing custom OpenAI implementations can remain source compatible without implementing this optional capability. Clients created by the SDK implement all operations.

Inheritors

Functions

Link copied to clipboard
open suspend fun conversation(id: ConversationId, requestOptions: RequestOptions? = null): Conversation?

Retrieves a conversation, or null when it does not exist.

open suspend fun conversation(request: ConversationRequest = ConversationRequest(), requestOptions: RequestOptions? = null): Conversation

Creates a conversation, optionally with initial items.

Link copied to clipboard
open suspend fun conversationItem(id: ConversationId, itemId: String, include: List<String>? = null, requestOptions: RequestOptions? = null): ConversationItem?

Retrieves an item, or null when it does not exist. Include requests additional item data.

Link copied to clipboard
open suspend fun conversationItems(id: ConversationId, limit: Int? = null, order: SortOrder? = null, after: String? = null, include: List<String>? = null, requestOptions: RequestOptions? = null): PaginatedList<ConversationItem>

Lists conversation items. Pass lastId as after to request the next page.

Link copied to clipboard
open suspend fun createConversationItems(id: ConversationId, request: ConversationItemsRequest, include: List<String>? = null, requestOptions: RequestOptions? = null): PaginatedList<ConversationItem>

Adds up to 20 items and returns the created items with pagination metadata.

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

Deletes a conversation. Returns false when it does not exist.

Link copied to clipboard
open suspend fun deleteConversationItem(id: ConversationId, itemId: String, requestOptions: RequestOptions? = null): Conversation

Removes an item and returns the updated conversation.

Link copied to clipboard
open suspend fun updateConversation(id: ConversationId, request: ConversationUpdateRequest, requestOptions: RequestOptions? = null): Conversation

Updates the supplied metadata keys, preserving existing keys that are not included.