MessagesResource class
Resource for Messages API operations (Beta).
Messages are the content within a thread conversation.
Access this resource through OpenAIClient.beta.threads.messages.
Example
// Create a message
final message = await client.beta.threads.messages.create(
'thread_abc123',
CreateMessageRequest(
role: 'user',
content: 'What is 2 + 2?',
),
);
// List messages
final messages = await client.beta.threads.messages.list('thread_abc123');
- Inheritance
-
- Object
- ResourceBase
- MessagesResource
Constructors
- MessagesResource({required OpenAIConfig config, required Client httpClient, required InterceptorChain interceptorChain, required RequestBuilder requestBuilder, void ensureNotClosed()?})
- Creates a MessagesResource.
Properties
- config → OpenAIConfig
-
Client configuration.
finalinherited
- ensureNotClosed → void Function()?
-
Callback to check if the client has been closed.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- httpClient → Client
-
HTTP client for making requests.
finalinherited
- interceptorChain → InterceptorChain
-
Interceptor chain for request/response processing.
finalinherited
- requestBuilder → RequestBuilder
-
Request builder for constructing HTTP requests.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- streamClientFactory → Client Function()?
-
Factory for creating dedicated HTTP clients for streaming requests.
finalinherited
Methods
-
create(
String threadId, CreateMessageRequest request) → Future< Message> - Creates a new message in a thread.
-
delete(
String threadId, String messageId) → Future< DeleteMessageResponse> - Deletes a message.
-
list(
String threadId, {int? limit, String? order, String? after, String? before, String? runId}) → Future< MessageList> - Lists messages in a thread.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
retrieve(
String threadId, String messageId) → Future< Message> - Retrieves a message by ID.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
String threadId, String messageId, ModifyMessageRequest request) → Future< Message> - Modifies a message.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited