YandexGPT API, REST: TextGenerationAsync.Instruct
RPC method for instructing the model to generate text.
HTTP request
POST https://llm.api.cloud.yandex.net/llm/v1alpha/instructAsync
Body parameters
{
"model": "string",
"generationOptions": {
"partialResults": "boolean",
"temperature": "number",
"maxTokens": "string"
},
// Includes only one of the fields `instructionText`, `instructionUri`
"instructionText": "string",
"instructionUri": "string",
// end of the list of possible fields
// Includes only one of the fields `requestText`
"requestText": "string"
// end of the list of possible fields
}
Request for instructing the model to generate text.
Field |
Description |
model |
string The name or identifier of the model to be used for text generation. |
generationOptions |
Configuration options for text generation. |
instructionText |
string The text-based instruction for text generation. Includes only one of the fields Text precondition or context of the request. |
instructionUri |
string A URI containing instructions for text generation. Includes only one of the fields Text precondition or context of the request. |
requestText |
string The text-based request for text generation. Includes only one of the fields Request for text generation. |
GenerationOptions
Defines the options for text generation.
Field |
Description |
partialResults |
boolean Enables streaming of partially generated text. |
temperature |
number (double) Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). |
maxTokens |
string (int64) Sets the maximum limit on the total number of tokens used for both the input prompt and the generated response. |
Response
HTTP Code: 200 - OK
{
"id": "string",
"description": "string",
"createdAt": "string",
"createdBy": "string",
"modifiedAt": "string",
"done": "boolean",
"metadata": "object",
// Includes only one of the fields `error`, `response`
"error": {
"code": "integer",
"message": "string",
"details": [
"object"
]
},
"response": {
"alternatives": [
{
"text": "string",
"score": "string",
"numTokens": "string"
}
],
"numPromptTokens": "string"
}
// end of the list of possible fields
}
An Operation resource. For more information, see Operation.
Field |
Description |
id |
string ID of the operation. |
description |
string Description of the operation. 0-256 characters long. |
createdAt |
string (date-time) Creation timestamp. String in RFC3339 To work with values in this field, use the APIs described in the |
createdBy |
string ID of the user or service account who initiated the operation. |
modifiedAt |
string (date-time) The time when the Operation resource was last modified. String in RFC3339 To work with values in this field, use the APIs described in the |
done |
boolean If the value is |
metadata |
object Service-specific metadata associated with the operation. |
error |
The error result of the operation in case of failure or cancellation. Includes only one of the fields The operation result. |
response |
The normal response of the operation in case of success. Includes only one of the fields The operation result. |
Status
The error result of the operation in case of failure or cancellation.
Field |
Description |
code |
integer (int32) Error code. An enum value of google.rpc.Code |
message |
string An error message. |
details[] |
object A list of messages that carry the error details. |
InstructResponse
Response containing generated text alternatives and token count.
Field |
Description |
alternatives[] |
A list of alternative text responses. |
numPromptTokens |
string (int64) The number of tokens used in the prompt, including both the instructionText and requestText. |
Alternative
Represents an alternative generated response, including its score and token count.
Field |
Description |
text |
string The generated text response. |
score |
string The score or confidence of the generated text. |
numTokens |
string (int64) The number of tokens in the generated response. |