Runs, REST: Run.GetLastByThread
- HTTP request
- Query parameters
- Response
- RunState
- Error
- Message
- Author
- MessageContent
- ContentPart
- Text
- Citation
- Source
- FileChunk
- SearchIndex
- ExpirationConfig
- TextSearchIndex
- ChunkingStrategy
- StaticChunkingStrategy
- NgramTokenizer
- VectorSearchIndex
- HybridSearchIndex
- CombinationStrategy
- MeanCombinationStrategy
- ReciprocalRankFusionCombinationStrategy
- File
- ChunkContent
- ToolCallList
- ToolCall
- FunctionCall
- ContentUsage
- PromptTruncationOptions
- LastMessagesStrategy
- CompletionOptions
- Tool
- SearchIndexTool
- FunctionTool
Retrieves the most recent run for a specific thread.
HTTP request
GET https://rest-assistant.api.cloud.yandex.net/assistants/v1/runs:getByThread
Query parameters
Request message for retrieving the last run associated with a specific thread.
Field |
Description |
threadId |
string Required field. ID of the thread for which the last run is being fetched. |
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`, `toolCallList`
"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",
"citations": [
{
"sources": [
{
// Includes only one of the fields `chunk`
"chunk": {
"searchIndex": {
"id": "string",
"folderId": "string",
"name": "string",
"description": "string",
"createdBy": "string",
"createdAt": "string",
"updatedBy": "string",
"updatedAt": "string",
"expirationConfig": {
"expirationPolicy": "string",
"ttlDays": "string"
},
"expiresAt": "string",
"labels": "object",
// Includes only one of the fields `textSearchIndex`, `vectorSearchIndex`, `hybridSearchIndex`
"textSearchIndex": {
"chunkingStrategy": {
// Includes only one of the fields `staticStrategy`
"staticStrategy": {
"maxChunkSizeTokens": "string",
"chunkOverlapTokens": "string"
}
// end of the list of possible fields
},
// Includes only one of the fields `ngramTokenizer`
"ngramTokenizer": {
"minGram": "string",
"maxGram": "string"
}
// end of the list of possible fields
},
"vectorSearchIndex": {
"docEmbedderUri": "string",
"queryEmbedderUri": "string",
"chunkingStrategy": {
// Includes only one of the fields `staticStrategy`
"staticStrategy": {
"maxChunkSizeTokens": "string",
"chunkOverlapTokens": "string"
}
// end of the list of possible fields
}
},
"hybridSearchIndex": {
"textSearchIndex": {
"chunkingStrategy": {
// Includes only one of the fields `staticStrategy`
"staticStrategy": {
"maxChunkSizeTokens": "string",
"chunkOverlapTokens": "string"
}
// end of the list of possible fields
},
// Includes only one of the fields `ngramTokenizer`
"ngramTokenizer": {
"minGram": "string",
"maxGram": "string"
}
// end of the list of possible fields
},
"vectorSearchIndex": {
"docEmbedderUri": "string",
"queryEmbedderUri": "string",
"chunkingStrategy": {
// Includes only one of the fields `staticStrategy`
"staticStrategy": {
"maxChunkSizeTokens": "string",
"chunkOverlapTokens": "string"
}
// end of the list of possible fields
}
},
"chunkingStrategy": {
// Includes only one of the fields `staticStrategy`
"staticStrategy": {
"maxChunkSizeTokens": "string",
"chunkOverlapTokens": "string"
}
// end of the list of possible fields
},
"normalizationStrategy": "string",
"combinationStrategy": {
// Includes only one of the fields `meanCombination`, `rrfCombination`
"meanCombination": {
"meanEvaluationTechnique": "string",
"weights": [
"string"
]
},
"rrfCombination": {
"k": "string"
}
// end of the list of possible fields
}
}
// end of the list of possible fields
},
"sourceFile": {
"id": "string",
"folderId": "string",
"name": "string",
"description": "string",
"mimeType": "string",
"createdBy": "string",
"createdAt": "string",
"updatedBy": "string",
"updatedAt": "string",
"expirationConfig": {
"expirationPolicy": "string",
"ttlDays": "string"
},
"expiresAt": "string",
"labels": "object"
},
"content": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
}
}
// end of the list of possible fields
}
]
}
]
},
"toolCallList": {
"toolCalls": [
{
// Includes only one of the fields `functionCall`
"functionCall": {
"name": "string",
"arguments": "object"
}
// end of the list of possible fields
}
]
}
// end of the list of possible fields
},
"usage": {
"promptTokens": "string",
"completionTokens": "string",
"totalTokens": "string"
},
"customPromptTruncationOptions": {
"maxPromptTokens": "string",
// Includes only one of the fields `autoStrategy`, `lastMessagesStrategy`
"autoStrategy": "object",
"lastMessagesStrategy": {
"numMessages": "string"
}
// end of the list of possible fields
},
"customCompletionOptions": {
"maxTokens": "string",
"temperature": "number"
},
"tools": [
{
// Includes only one of the fields `searchIndex`, `function`
"searchIndex": {
"searchIndexIds": [
"string"
],
"maxNumResults": "string"
},
"function": {
"name": "string",
"description": "string",
"parameters": "object"
}
// end of the list of possible fields
}
]
}
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. |
tools[] |
List of tools that are available for the assistant to use in this run. |
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. |
toolCallList |
A list of tool calls requested by the assistant. 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.
|
citations[] |
List of citations used to generate 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. |
Citation
Represents a citation used for generating a message.
Field |
Description |
sources[] |
List of sources for citation. |
Source
Represents a source used for generating a message citation.
Field |
Description |
chunk |
File chunk source. Includes only one of the fields Specifies the type of source type. |
FileChunk
FileChunk represents a chunk of a file used as a source.
Field |
Description |
searchIndex |
Search index associated with the file chunk. |
sourceFile |
The original file from which the chunk is derived. |
content |
Content of the file chunk. |
SearchIndex
Represents a search index used to store and query data, either using traditional keyword-based text search or vector-based search mechanisms.
Field |
Description |
id |
string Unique identifier of the search index. |
folderId |
string ID of the folder that the search index belongs to. |
name |
string Name of the search index. |
description |
string Description of the search index. |
createdBy |
string Identifier of the subject who created this search index. |
createdAt |
string (date-time) Timestamp representing when the search index was created. String in RFC3339 To work with values in this field, use the APIs described in the |
updatedBy |
string Identifier of the subject who last updated this search index. |
updatedAt |
string (date-time) Timestamp representing the last time this search index was updated. String in RFC3339 To work with values in this field, use the APIs described in the |
expirationConfig |
Configuration for the expiration of the search index, defining when and how the search index will expire. |
expiresAt |
string (date-time) Timestamp representing when the search index will expire. 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 search index. |
textSearchIndex |
Keyword-based text search index configuration. Includes only one of the fields Type of the search index. It can be either a traditional keyword-based text search or a vector-based search. |
vectorSearchIndex |
Vector-based search index configuration. Includes only one of the fields Type of the search index. It can be either a traditional keyword-based text search or a vector-based search. |
hybridSearchIndex |
Hybrid (vector-based + keyword-based) search index configuration Includes only one of the fields Type of the search index. It can be either a traditional keyword-based text search or a vector-based search. |
ExpirationConfig
Field |
Description |
expirationPolicy |
enum (ExpirationPolicy)
|
ttlDays |
string (int64) |
TextSearchIndex
Defines the configuration for a traditional keyword-based text search index.
Field |
Description |
chunkingStrategy |
Chunking strategy used to split text into smaller chunks before indexing. |
ngramTokenizer |
Tokenizer that generates n-grams. Includes only one of the fields Tokenizer type used for text search. The tokenizer determines how the |
ChunkingStrategy
Defines a general strategy for chunking text into smaller segments.
Currently, only StaticChunkingStrategy is supported.
Field |
Description |
staticStrategy |
Includes only one of the fields |
StaticChunkingStrategy
Defines a chunking strategy where chunks are created with a fixed maximum chunk size and an overlap between consecutive chunks.
Field |
Description |
maxChunkSizeTokens |
string (int64) The maximum number of tokens allowed in a single chunk. |
chunkOverlapTokens |
string (int64) The number of tokens that should overlap between consecutive chunks. |
NgramTokenizer
Configuration for the NgramTokenizer, which splits text into overlapping character sequences (n-grams) of specified lengths.
Example:
Input text: hello
min_gram = 2, max_gram = 3
Generated tokens:
- For n = 2 (2-character n-grams):
he
,el
,ll
,lo
- For n = 3 (3-character n-grams):
hel
,ell
,llo
Final tokens: [he, el, ll, lo, hel, ell, llo]
Field |
Description |
minGram |
string (int64) Minimum length of characters in a gram. Defaults to 3 |
maxGram |
string (int64) Maximum length of characters in a gram. Defaults to 4 |
VectorSearchIndex
Defines the configuration for a vector-based search index. This type uses embeddings to represent documents and queries.
Field |
Description |
docEmbedderUri |
string The ID of the model to be used for obtaining document text embeddings. |
queryEmbedderUri |
string The ID of the model to be used for obtaining query text embeddings. |
chunkingStrategy |
Chunking strategy used to split text into smaller chunks before indexing. |
HybridSearchIndex
Defines the configuration for a hybrid (vector-based + keyword-based) search index. This type uses both embeddings and keyword-based search to represent documents and queries.
Field |
Description |
textSearchIndex |
Configuration for a traditional keyword-based text search index. |
vectorSearchIndex |
Configuration for a vector-based search index. |
chunkingStrategy |
Common chunking strategy that applies to both text and vector search indexes. |
normalizationStrategy |
enum (NormalizationStrategy) Normalization strategy for relevance scores from different indices. Default is MIN_MAX_STRATEGY
|
combinationStrategy |
Combination strategy for merging rankings from different indices. Default is arithmetic mean |
CombinationStrategy
Combination strategy for merging rankings from different indices
Field |
Description |
meanCombination |
Includes only one of the fields |
rrfCombination |
ReciprocalRankFusionCombinationStrategy Includes only one of the fields |
MeanCombinationStrategy
Field |
Description |
meanEvaluationTechnique |
enum (MeanEvaluationTechnique) Technique for averaging relevance scores from different indices. Default is ARITHMETIC
|
weights[] |
string Weights used for evaluating the weighted mean of relevance scores. The sum of the values must equal 1.0 |
ReciprocalRankFusionCombinationStrategy
https://plg.uwaterloo.ca/~gvcormac/cormacksigir09-rrf.pdf
Field |
Description |
k |
string (int64) The parameter k for RRFscore. Default is 60 |
File
Field |
Description |
id |
string Unique identifier of the file. |
folderId |
string ID of the folder that the file belongs to. |
name |
string Name of the file. |
description |
string Description of the file. |
mimeType |
string MIME type of the file, indicating the file's format (e.g., "application/pdf") |
createdBy |
string Identifier of the subject who created this file. |
createdAt |
string (date-time) Timestamp representing when the file was created. String in RFC3339 To work with values in this field, use the APIs described in the |
updatedBy |
string Identifier of the subject who last updated this file. |
updatedAt |
string (date-time) Timestamp representing the last time this file was updated. String in RFC3339 To work with values in this field, use the APIs described in the |
expirationConfig |
Configuration for the expiration of the file, defining when and how the file will expire. |
expiresAt |
string (date-time) Timestamp representing when the file will expire. 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 file. |
ChunkContent
Represents the content of a file chunk.
Field |
Description |
content[] |
A list of content parts that make up the chunk. |
ToolCallList
Represents a list of tool calls.
Field |
Description |
toolCalls[] |
A list of tool calls to be executed. |
ToolCall
Represents a call to a tool.
Field |
Description |
functionCall |
Represents a call to a function. Includes only one of the fields |
FunctionCall
Represents the invocation of a function with specific arguments.
Field |
Description |
name |
string The name of the function being called. |
arguments |
object The structured arguments passed to the function. |
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. |
autoStrategy |
object Includes only one of the fields Specifies the truncation strategy to use when the prompt exceeds the token limit. |
lastMessagesStrategy |
Retains only the last Includes only one of the fields Specifies the truncation strategy to use when the prompt exceeds the token limit. |
LastMessagesStrategy
Truncates the prompt by retaining only the last num_messages
messages in the thread.
Field |
Description |
numMessages |
string (int64) The number of most recent messages to retain 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). |
Tool
Represents a general tool that can be one of several types.
Field |
Description |
searchIndex |
SearchIndexTool tool that performs search across specified indexes. Includes only one of the fields |
function |
Function tool that can be invoked by the assistant. Includes only one of the fields |
SearchIndexTool
Configures a tool that enables Retrieval-Augmented Generation (RAG) by allowing the assistant to search across a specified search index.
Field |
Description |
searchIndexIds[] |
string A list of search index IDs that this tool will query. Currently, only a single index ID is supported. |
maxNumResults |
string (int64) The maximum number of results to return from the search. |
FunctionTool
Represents a function tool that can be invoked by the assistant.
Field |
Description |
name |
string The name of the function. |
description |
string A description of the function's purpose or behavior. |
parameters |
object A JSON Schema that defines the expected parameters for the function. |