Conversations API

Create, retrieve, update, and delete durable, server-side conversations, and manage their items. A conversation id feeds the Responses API for multi-turn exchanges without resending history. OpenAI only.

Parsed Objects

UniLM.ConversationObjectType
ConversationObject

A durable, server-side conversation: id, optional created_at and metadata; raw holds the unparsed JSON response.

source
UniLM.ConversationItemType
ConversationItem

A single item in a conversation: id and optional type; raw holds the unparsed JSON response.

source

Result Types

Request Functions

UniLM.create_conversationFunction
create_conversation(; items=nothing, metadata=nothing, service=OPENAIServiceEndpoint)

Create a conversation. items is an optional vector of input items (e.g. InputMessage). Returns ConversationSuccess, ConversationFailure, or ConversationCallError.

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.retrieve_conversationFunction
retrieve_conversation(id; service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.update_conversationFunction
update_conversation(id, metadata; service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.delete_conversationFunction
delete_conversation(id; service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.add_conversation_itemsFunction
add_conversation_items(conversation_id, items; service=OPENAIServiceEndpoint)

Append input items to a conversation. Returns ConversationItemListSuccess.

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.list_conversation_itemsFunction
list_conversation_items(conversation_id; limit=nothing, order=nothing, after=nothing, service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source
UniLM.delete_conversation_itemFunction
delete_conversation_item(conversation_id, item_id; service=OPENAIServiceEndpoint)

Pass config::Union{Nothing,RequestConfig} to override the timeout budget for this call (a single bounded attempt; max_attempts does not apply).

source

Accessors

Usage

# Create a durable, server-side conversation
result = create_conversation(metadata=Dict("topic" => "support"))
result isa ConversationSuccess && println("Created: ", conversation_id(result.response))

# Retrieve, then update its metadata
retrieve_conversation("conv_abc123")
update_conversation("conv_abc123", Dict("status" => "closed"))

# Add items, list them, then clean up
add_conversation_items("conv_abc123", [InputMessage(role="user", content="Hello")])
items = list_conversation_items("conv_abc123", limit=20)
delete_conversation_item("conv_abc123", "msg_xyz")
delete_conversation("conv_abc123")