Table of Contents

Class MessageResponse

Namespace
OpenAI.Threads
Assembly
OpenAI-DotNet.dll

A message created by an Assistant or a user. Messages can include text, images, and other files. Messages stored as a list on the Thread.

public sealed class MessageResponse : BaseResponse, IServerSentEvent
Inheritance
MessageResponse
Implements
Inherited Members
Extension Methods

Constructors

MessageResponse()

public MessageResponse()

Properties

AssistantId

If applicable, the ID of the assistant that authored this message.

[JsonInclude]
[JsonPropertyName("assistant_id")]
public string AssistantId { get; }

Property Value

string

Attachments

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

[JsonInclude]
[JsonPropertyName("attachments")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public IReadOnlyList<Attachment> Attachments { get; }

Property Value

IReadOnlyList<Attachment>

CompletedAt

[JsonIgnore]
public DateTime? CompletedAt { get; }

Property Value

DateTime?

CompletedAtUnixTimeSeconds

The Unix timestamp (in seconds) for when the message was completed.

[JsonInclude]
[JsonPropertyName("completed_at")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? CompletedAtUnixTimeSeconds { get; }

Property Value

int?

Content

The content of the message in array of text and/or images.

[JsonInclude]
[JsonPropertyName("content")]
public IReadOnlyList<Content> Content { get; }

Property Value

IReadOnlyList<Content>

CreatedAt

[JsonIgnore]
public DateTime CreatedAt { get; }

Property Value

DateTime

CreatedAtUnixTimeSeconds

The Unix timestamp (in seconds) for when the message was created.

[JsonInclude]
[JsonPropertyName("created_at")]
public int CreatedAtUnixTimeSeconds { get; }

Property Value

int

Delta

[JsonInclude]
[JsonPropertyName("delta")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public MessageDelta Delta { get; }

Property Value

MessageDelta

Id

The identifier, which can be referenced in API endpoints.

[JsonInclude]
[JsonPropertyName("id")]
public string Id { get; }

Property Value

string

IncompleteAt

[JsonIgnore]
public DateTime? IncompleteAt { get; }

Property Value

DateTime?

IncompleteAtUnixTimeSeconds

The Unix timestamp (in seconds) for when the message was marked as incomplete.

[JsonInclude]
[JsonPropertyName("incomplete_at")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? IncompleteAtUnixTimeSeconds { get; }

Property Value

int?

IncompleteDetails

On an incomplete message, details about why the message is incomplete.

[JsonInclude]
[JsonPropertyName("incomplete_details")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public IncompleteDetails IncompleteDetails { get; }

Property Value

IncompleteDetails

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.

[JsonInclude]
[JsonPropertyName("metadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public IReadOnlyDictionary<string, string> Metadata { get; }

Property Value

IReadOnlyDictionary<string, string>

Object

The object type, which is always message.

[JsonInclude]
[JsonPropertyName("object")]
public string Object { get; }

Property Value

string

Role

The entity that produced the message. One of user or assistant.

[JsonInclude]
[JsonPropertyName("role")]
public Role Role { get; }

Property Value

Role

RunId

If applicable, the ID of the run associated with the authoring of this message.

[JsonInclude]
[JsonPropertyName("run_id")]
public string RunId { get; }

Property Value

string

Status

The status of the message, which can be either 'in_progress', 'incomplete', or 'completed'.

[JsonInclude]
[JsonPropertyName("status")]
[JsonConverter(typeof(JsonStringEnumConverter<MessageStatus>))]
public MessageStatus Status { get; }

Property Value

MessageStatus

ThreadId

The thread ID that this message belongs to.

[JsonInclude]
[JsonPropertyName("thread_id")]
public string ThreadId { get; }

Property Value

string

Methods

FromSchema<T>(JsonSerializerOptions)

Converts the Content to the specified JsonSchema.

public T FromSchema<T>(JsonSerializerOptions options = null)

Parameters

options JsonSerializerOptions

JsonSerializerOptions.

Returns

T

Deserialized JsonSchema object.

Type Parameters

T

JsonSchema to used for structured outputs.

PrintContent()

Formats all of the Content items into a single string, putting each item on a new line.

public string PrintContent()

Returns

string

string of all Content.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

implicit operator Message(MessageResponse)

public static implicit operator Message(MessageResponse response)

Parameters

response MessageResponse

Returns

Message

implicit operator string(MessageResponse)

public static implicit operator string(MessageResponse message)

Parameters

message MessageResponse

Returns

string