Table of Contents

Class ConversationsEndpoint

Namespace
OpenAI.Responses
Assembly
OpenAI-DotNet.dll
public sealed class ConversationsEndpoint : OpenAIBaseEndpoint
Inheritance
ConversationsEndpoint
Inherited Members

Constructors

ConversationsEndpoint(OpenAIClient)

public ConversationsEndpoint(OpenAIClient client)

Parameters

client OpenAIClient

Properties

Root

The root endpoint address.

protected override string Root { get; }

Property Value

string

Methods

CreateConversationAsync(CreateConversationRequest, CancellationToken)

Create a conversation.

public Task<Conversation> CreateConversationAsync(CreateConversationRequest request, CancellationToken cancellationToken = default)

Parameters

request CreateConversationRequest

CreateConversationRequest.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<Conversation>

Conversation.

CreateConversationItemsAsync(string, IEnumerable<IResponseItem>, string[], CancellationToken)

Create items in a conversation with the given ID.

public Task<ListResponse<IResponseItem>> CreateConversationItemsAsync(string conversationId, IEnumerable<IResponseItem> items, string[] include = null, CancellationToken cancellationToken = default)

Parameters

conversationId string

The ID of the conversation to add the item to.

items IEnumerable<IResponseItem>

The items to add to the conversation. You may add up to 20 items at a time.

include string[]

Optional, Additional fields to include in the response.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<ListResponse<IResponseItem>>

ListResponse<TObject>.

DeleteConversationAsync(string, CancellationToken)

Delete a conversation.

public Task<bool> DeleteConversationAsync(string conversationId, CancellationToken cancellationToken = default)

Parameters

conversationId string

The id of the conversation to retrieve.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<bool>

True, if the Conversation was deleted successfully, otherwise False.

Remarks

Items in the conversation will not be deleted.

DeleteConversationItemAsync(string, string, CancellationToken)

Delete an item from a conversation with the given IDs.

public Task<Conversation> DeleteConversationItemAsync(string conversationId, string itemId, CancellationToken cancellationToken = default)

Parameters

conversationId string

The ID of the conversation that contains the item.

itemId string

The ID of the item to delete.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<Conversation>

Returns the updated Conversation>.

GetConversationAsync(string, CancellationToken)

Get a conversation.

public Task<Conversation> GetConversationAsync(string conversationId, CancellationToken cancellationToken = default)

Parameters

conversationId string

The id of the conversation to retrieve.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<Conversation>

Conversation.

GetConversationItemAsync(string, string, string[], CancellationToken)

Retrieve an item from a conversation.

public Task<IResponseItem> GetConversationItemAsync(string conversationId, string itemId, string[] include = null, CancellationToken cancellationToken = default)

Parameters

conversationId string

The ID of the conversation that contains the item.

itemId string

The ID of the item to retrieve.

include string[]

Optional, Additional fields to include in the response.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<IResponseItem>

IResponseItem.

ListConversationItemsAsync(string, ListQuery, CancellationToken)

List all items for a conversation with the given ID.

public Task<ListResponse<IResponseItem>> ListConversationItemsAsync(string conversationId, ListQuery query = null, CancellationToken cancellationToken = default)

Parameters

conversationId string

The ID of the conversation to list items for.

query ListQuery

Optional, ListQuery.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<ListResponse<IResponseItem>>

ListResponse<TObject>.

UpdateConversationAsync(string, IReadOnlyDictionary<string, string>, CancellationToken)

Update a conversation.

public Task<Conversation> UpdateConversationAsync(string conversationId, IReadOnlyDictionary<string, string> metadata, CancellationToken cancellationToken = default)

Parameters

conversationId string

The id of the conversation to retrieve.

metadata IReadOnlyDictionary<string, string>

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters.Values are strings with a maximum length of 512 characters.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<Conversation>

Conversation.