Table of Contents

Class ThreadMessage

Represents a message within a thread.

[Serializable]
public class ThreadMessage : Message, IPromptWithFiles, IPrompt, IModeratable
Inheritance
object
ThreadMessage
Implements
Inherited Members
Extension Methods

Constructors

ThreadMessage()

public ThreadMessage()

ThreadMessage(ChatRole, string)

public ThreadMessage(ChatRole role, string content = null)

Parameters

role ChatRole
content string

Properties

AssistantId

If applicable, the Assistant that authored this message.

public string AssistantId { get; set; }

Property Value

string

Attachments

A list of files attached to the message, and the tools they were added to.

public Attachment[] Attachments { get; set; }

Property Value

Attachment[]

Metadata

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. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.

public ServerDictionary Metadata { get; set; }

Property Value

ServerDictionary

Object

The OpenAI object type

public string Object { get; set; }

Property Value

string

Role

The role of the messages author.

Role is abstract and overridden in derived classes to enforce consistency.
This avoids relying on constructor or deserialization logic to set the role.
JSON.NET does not call parameterized constructors or set get-only properties during deserialization.

public override ChatRole Role { get; }

Property Value

ChatRole

RunId

The Run associated with the creation of this message. Value is null when messages are created manually using the create message or create thread endpoints.

public string RunId { get; set; }

Property Value

string

ToolCallId

Required. Tool call that this message is responding to.

public string ToolCallId { get; set; }

Property Value

string

Tools

A list of tool calls (functions) the model wants to use.

public ToolCall[] Tools { get; set; }

Property Value

ToolCall[]

Usage

Usage metadata for the message.

public UsageMetadata Usage { get; set; }

Property Value

UsageMetadata

Methods

CreateContentJToken(List<StringOr<ContentPart>>, JsonSerializer)

public static JToken CreateContentJToken(List<StringOr<ContentPart>> partWrappers, JsonSerializer serializer)

Parameters

partWrappers List<StringOr<ContentPart>>
serializer JsonSerializer

Returns

JToken

CreateRequest(string)

public static ThreadMessageRequest CreateRequest(string textPrompt)

Parameters

textPrompt string

Returns

ThreadMessageRequest

CreateRequest(string, params File<Texture2D>[])

public static ThreadMessageRequest CreateRequest(string textPrompt, params File<Texture2D>[] imageFiles)

Parameters

textPrompt string
imageFiles File<Texture2D>[]

Returns

ThreadMessageRequest

CreateRequest(string, params string[])

public static ThreadMessageRequest CreateRequest(string textPrompt, params string[] imageUrls)

Parameters

textPrompt string
imageUrls string[]

Returns

ThreadMessageRequest