Runs, REST: Run.Create
Create a new run for a given assistant and thread.
HTTP request
POST https://rest-assistant.api.cloud.yandex.net/assistants/v1/runs
Body parameters
{
"assistantId": "string",
"threadId": "string",
"labels": "object",
"additionalMessages": [
{
"author": {
"id": "string",
"role": "string"
},
"labels": "object",
"content": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
}
}
],
"customPromptTruncationOptions": {
"maxPromptTokens": "string"
},
"customCompletionOptions": {
"maxTokens": "string",
"temperature": "number"
},
"stream": "boolean"
}
Request message for creating a new run.
Field |
Description |
assistantId |
string Required field. ID of the assistant for which the run is being created |
threadId |
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. |
additionalMessages[] |
Additional messages that will be written to the thread before the run starts. |
customPromptTruncationOptions |
Configuration options for truncating the prompt when the token count exceeds a specified limit. |
customCompletionOptions |
Configuration options for completion generation. |
stream |
boolean 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 |
maxPromptTokens |
string (int64) The maximum number of tokens allowed in the prompt. |
CompletionOptions
Defines the options for completion generation.
Field |
Description |
maxTokens |
string (int64) The limit on the number of tokens used for single completion generation. |
temperature |
number (double) Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). |
Response
HTTP Code: 200 - OK
{
"id": "string",
"assistantId": "string",
"threadId": "string",
"createdBy": "string",
"createdAt": "string",
"labels": "object",
"state": {
"status": "string",
// Includes only one of the fields `error`, `completedMessage`
"error": {
"code": "string",
"message": "string"
},
"completedMessage": {
"id": "string",
"threadId": "string",
"createdBy": "string",
"createdAt": "string",
"author": {
"id": "string",
"role": "string"
},
"labels": "object",
"content": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
},
"status": "string"
}
// end of the list of possible fields
},
"usage": {
"promptTokens": "string",
"completionTokens": "string",
"totalTokens": "string"
},
"customPromptTruncationOptions": {
"maxPromptTokens": "string"
},
"customCompletionOptions": {
"maxTokens": "string",
"temperature": "number"
}
}
Represents a run of an assistant over a specific thread of messages.
Field |
Description |
id |
string Unique identifier of the run. |
assistantId |
string Identifier for the assistant that is being run. |
threadId |
string Identifier for the thread of messages that this run is associated with. |
createdBy |
string Identifier of the subject who created this run. |
createdAt |
string (date-time) Timestamp representing when the run was created. String in RFC3339 To work with values in this field, use the APIs described in the |
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. |
customPromptTruncationOptions |
Configuration options for truncating the prompt when the token count exceeds a specified limit. |
customCompletionOptions |
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. |
completedMessage |
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 |
string (int64) |
message |
string |
Message
Field |
Description |
id |
string Unique identifier of the message. |
threadId |
string ID of the thread that this message belongs to. |
createdBy |
string Identifier of the subject who created this message. |
createdAt |
string (date-time) Timestamp representing when the message was created. String in RFC3339 To work with values in this field, use the APIs described in the |
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 |
promptTokens |
string (int64) The number of tokens used in the prompt. |
completionTokens |
string (int64) The number of tokens used in the completion response. |
totalTokens |
string (int64) The total number of tokens used (prompt + completion). |
PromptTruncationOptions
Defines the options for truncating thread messages within a prompt.
Field |
Description |
maxPromptTokens |
string (int64) The maximum number of tokens allowed in the prompt. |
CompletionOptions
Defines the options for completion generation.
Field |
Description |
maxTokens |
string (int64) The limit on the number of tokens used for single completion generation. |
temperature |
number (double) Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). |