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": true,
"temperature": "number",
"maxTokens": "integer"
},
// includes only one of the fields `instructionText`, `instructionUri`
"instructionText": "string",
"instructionUri": "string",
// end of the list of possible fields
"requestText": "string"
}
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. Possible value for now: The maximum string length in characters is 50. |
generationOptions | object Configuration options for text generation. |
generationOptions. partialResults |
boolean (boolean) Enables streaming of partially generated text. |
generationOptions. temperature |
number (double) Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). Lower values produce more straightforward responses, while higher values lead to increased creativity and randomness. |
generationOptions. maxTokens |
integer (int64) Sets the maximum limit on the total number of tokens used for both the input prompt and the generated response. Must be greater than zero and not exceed 7400 tokens. |
instructionText | string includes only one of the fields instructionText , instructionUri The text-based instruction for text generation. |
instructionUri | string includes only one of the fields instructionText , instructionUri A URI containing instructions for text generation. |
requestText | string The text-based request for text generation. |
Response
HTTP Code: 200 - OK
{
"alternatives": [
{
"text": "string",
"score": "number",
"numTokens": "string"
}
],
"numPromptTokens": "string"
}
Response containing generated text alternatives and token count.
Field | Description |
---|---|
alternatives[] | object A list of alternative text responses. |
alternatives[]. text |
string The generated text response. |
alternatives[]. score |
number (double) The score or confidence of the generated text. |
alternatives[]. numTokens |
string (int64) The number of tokens in the generated response. |
numPromptTokens | string (int64) The number of tokens used in the prompt, including both the [instruction_text] and [request_text]. |