Share via


AssistantsClient.CreateMessageAsync Method

Definition

Creates a new message on a specified thread.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.OpenAI.Assistants.ThreadMessage>> CreateMessageAsync (string threadId, Azure.AI.OpenAI.Assistants.MessageRole role, string content, System.Collections.Generic.IEnumerable<string> fileIds = default, System.Collections.Generic.IDictionary<string,string> metadata = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateMessageAsync : string * Azure.AI.OpenAI.Assistants.MessageRole * string * seq<string> * System.Collections.Generic.IDictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.OpenAI.Assistants.ThreadMessage>>
override this.CreateMessageAsync : string * Azure.AI.OpenAI.Assistants.MessageRole * string * seq<string> * System.Collections.Generic.IDictionary<string, string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.OpenAI.Assistants.ThreadMessage>>
Public Overridable Function CreateMessageAsync (threadId As String, role As MessageRole, content As String, Optional fileIds As IEnumerable(Of String) = Nothing, Optional metadata As IDictionary(Of String, String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of ThreadMessage))

Parameters

threadId
String

The ID of the thread to create the new message on.

role
MessageRole

The role to associate with the new message.

content
String

The textual content for the new message.

fileIds
IEnumerable<String>

A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files.

metadata
IDictionary<String,String>

A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

threadId or content is null.

threadId is an empty string, and was expected to be non-empty.

Applies to