Class ThreadMessage
Represents a message within a thread.
[Serializable]
public class ThreadMessage : Message, IPromptWithFiles, IPrompt, IModeratable
- Inheritance
-
objectThreadMessage
- Implements
- Inherited Members
- Extension Methods
Constructors
ThreadMessage()
public ThreadMessage()
ThreadMessage(ChatRole, string)
public ThreadMessage(ChatRole role, string content = null)
Parameters
roleChatRolecontentstring
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
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
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
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
Methods
CreateContentJToken(List<StringOr<ContentPart>>, JsonSerializer)
public static JToken CreateContentJToken(List<StringOr<ContentPart>> partWrappers, JsonSerializer serializer)
Parameters
partWrappersList<StringOr<ContentPart>>serializerJsonSerializer
Returns
- JToken
CreateRequest(string)
public static ThreadMessageRequest CreateRequest(string textPrompt)
Parameters
textPromptstring
Returns
CreateRequest(string, params File<Texture2D>[])
public static ThreadMessageRequest CreateRequest(string textPrompt, params File<Texture2D>[] imageFiles)
Parameters
textPromptstringimageFilesFile<Texture2D>[]
Returns
CreateRequest(string, params string[])
public static ThreadMessageRequest CreateRequest(string textPrompt, params string[] imageUrls)
Parameters
textPromptstringimageUrlsstring[]