Runs, gRPC: RunService.Listen
Listen to events from a specific run.
If the run was created with stream = false
, Listen will only respond with the final status of the run
and will not stream partial messages or intermediate events.
gRPC request
rpc Listen (ListenRunRequest) returns (stream StreamEvent)
ListenRunRequest
{
"run_id": "string",
"events_start_idx": "google.protobuf.Int64Value"
}
Request message for listing to a run events.
Field |
Description |
run_id |
string Required field. ID of the run to listen to. |
events_start_idx |
Starting index for events. If provided, listening will start from this event. |
StreamEvent
{
"event_type": "EventType",
"stream_cursor": {
"current_event_idx": "int64",
"num_user_events_received": "int64"
},
// Includes only one of the fields `error`, `partial_message`, `completed_message`
"error": {
"code": "int64",
"message": "string"
},
"partial_message": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
},
"completed_message": {
"id": "string",
"thread_id": "string",
"created_by": "string",
"created_at": "google.protobuf.Timestamp",
"author": {
"id": "string",
"role": "string"
},
"labels": "map<string, string>",
"content": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
},
"status": "MessageStatus"
}
// end of the list of possible fields
}
Represents an event in the stream of a run.
Field |
Description |
event_type |
enum EventType The type of event.
|
stream_cursor |
The current position in the stream. |
error |
Error information if the run has failed. Includes only one of the fields Event data, which can be one of several types. |
partial_message |
Partially generated message. Includes only one of the fields Event data, which can be one of several types. |
completed_message |
Final message generated by an assistant if a run has completed successfully. Includes only one of the fields Event data, which can be one of several types. |
StreamCursor
Represents the cursor position in a stream of events.
Field |
Description |
current_event_idx |
int64 Index of the current event in the stream. |
num_user_events_received |
int64 The number of user events received so far. |
Error
Field |
Description |
code |
int64 |
message |
string |
MessageContent
Represents the content of a message, which can consist of multiple parts.
Field |
Description |
content[] |
A list of content parts that make up the message. |
ContentPart
ContentPart represents an individual part of the message content, which can be of various types.
Field |
Description |
text |
Text content of the message part. Includes only one of the fields Specifies the type of content that the part contains. |
Text
Text represents a textual content part of a message.
Field |
Description |
content |
string Text content of the message. |
Message
Field |
Description |
id |
string Unique identifier of the message. |
thread_id |
string ID of the thread that this message belongs to. |
created_by |
string Identifier of the subject who created this message. |
created_at |
Timestamp representing when the message was created. |
author |
Author of the message, containing details about the message's creator. |
labels |
object (map<string, string>) Set of key-value pairs that can be used to organize and categorize the message. |
content |
Content of the message. |
status |
enum MessageStatus Status of the message.
|
Author
Author of the message, containing details about the message's creator.
Field |
Description |
id |
string Unique identifier of the author. This could be either the user's ID or the assistant's ID, depending on the role. |
role |
string Role of the author, indicating whether the message was created by a "user" or an "assistant". |