Runs, gRPC: RunService.Create
Create a new run for a given assistant and thread.
gRPC request
rpc Create (CreateRunRequest) returns (Run)
CreateRunRequest
{
"assistant_id": "string",
"thread_id": "string",
"labels": "map<string, string>",
"additional_messages": [
{
"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
}
]
}
}
],
"custom_prompt_truncation_options": {
"max_prompt_tokens": "google.protobuf.Int64Value"
},
"custom_completion_options": {
"max_tokens": "google.protobuf.Int64Value",
"temperature": "google.protobuf.DoubleValue"
},
"stream": "bool"
}
Request message for creating a new run.
Field |
Description |
assistant_id |
string Required field. ID of the assistant for which the run is being created |
thread_id |
string Required field. ID of the thread associated with the run. |
labels |
object (map<string, string>) Set of key-value pairs to label the run. |
additional_messages[] |
Additional messages that will be written to the thread before the run starts. |
custom_prompt_truncation_options |
Configuration options for truncating the prompt when the token count exceeds a specified limit. |
custom_completion_options |
Configuration options for completion generation. |
stream |
bool Enables streaming of intermediate events, such as partial messages. |
MessageData
Represents the data required to create or initialize a message in a thread.
This message is used, for example, to initialize a thread with some messages upon its creation.
Field |
Description |
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. |
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". |
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. |
PromptTruncationOptions
Defines the options for truncating thread messages within a prompt.
Field |
Description |
max_prompt_tokens |
The maximum number of tokens allowed in the prompt. |
CompletionOptions
Defines the options for completion generation.
Field |
Description |
max_tokens |
The limit on the number of tokens used for single completion generation. |
temperature |
Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). |
Run
{
"id": "string",
"assistant_id": "string",
"thread_id": "string",
"created_by": "string",
"created_at": "google.protobuf.Timestamp",
"labels": "map<string, string>",
"state": {
"status": "RunStatus",
// Includes only one of the fields `error`, `completed_message`
"error": {
"code": "int64",
"message": "string"
},
"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
},
"usage": {
"prompt_tokens": "int64",
"completion_tokens": "int64",
"total_tokens": "int64"
},
"custom_prompt_truncation_options": {
"max_prompt_tokens": "google.protobuf.Int64Value"
},
"custom_completion_options": {
"max_tokens": "google.protobuf.Int64Value",
"temperature": "google.protobuf.DoubleValue"
}
}
Represents a run of an assistant over a specific thread of messages.
Field |
Description |
id |
string Unique identifier of the run. |
assistant_id |
string Identifier for the assistant that is being run. |
thread_id |
string Identifier for the thread of messages that this run is associated with. |
created_by |
string Identifier of the subject who created this run. |
created_at |
Timestamp representing when the run was created. |
labels |
object (map<string, string>) Set of key-value pairs that can be used to organize and categorize the run. |
state |
Current state of the run, including its status and any associated data. |
usage |
Information about the content usage during the run, such as the number of tokens used by the completion model. |
custom_prompt_truncation_options |
Configuration options for truncating the prompt when the token count exceeds a specified limit. |
custom_completion_options |
Configuration options for completion generation. |
RunState
Represents the current state of a run.
Field |
Description |
status |
enum RunStatus Current status of a run.
|
error |
Error information if a run has failed. Includes only one of the fields Oneof field to capture additional data depending on the state of a run. |
completed_message |
Final message generated by an assistant if a run has completed successfully. Includes only one of the fields Oneof field to capture additional data depending on the state of a run. |
Error
Field |
Description |
code |
int64 |
message |
string |
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". |
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. |
ContentUsage
Represents the content usage during a run, such as the number of tokens used by the completion model.
Field |
Description |
prompt_tokens |
int64 The number of tokens used in the prompt. |
completion_tokens |
int64 The number of tokens used in the completion response. |
total_tokens |
int64 The total number of tokens used (prompt + completion). |
PromptTruncationOptions
Defines the options for truncating thread messages within a prompt.
Field |
Description |
max_prompt_tokens |
The maximum number of tokens allowed in the prompt. |
CompletionOptions
Defines the options for completion generation.
Field |
Description |
max_tokens |
The limit on the number of tokens used for single completion generation. |
temperature |
Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). |