YandexGPT API, REST: TextGeneration.Instruct
RPC method for instructing the model to generate text.
HTTP request
POST https://llm.api.cloud.yandex.net/llm/v1alpha/instruct
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
{
"alternatives": [
{
"text": "string",
"score": "string",
"numTokens": "string"
}
],
"numPromptTokens": "string"
}
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. |