Foundation Models Text Generation API, REST: TextGeneration.completion
A method for generating text completions in synchronous mode.
HTTP request
POST https://llm.api.cloud.yandex.net/foundationModels/v1/completion
Body parameters
{
"modelUri": "string",
"completionOptions": {
"stream": true,
"temperature": "number",
"maxTokens": "integer"
},
"messages": [
{
"role": "string",
"text": "string"
}
]
}
Request for the service to generate text completion.
Field | Description |
---|---|
modelUri | string The ID of the model to be used for completion generation. |
completionOptions | object Configuration options for completion generation. Defines the options for completion generation. |
completionOptions. stream |
boolean (boolean) Enables streaming of partially generated text. |
completionOptions. 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. Default temperature: 0.3 |
completionOptions. maxTokens |
integer (int64) The limit on the number of tokens used for single completion generation. Must be greater than zero. This maximum allowed parameter value may depend on the model being used. |
messages[] | object A list of messages representing the context for the completion model. |
messages[]. role |
string The ID of the message sender. Supported roles:
|
messages[]. text |
string Textual content of the message. |
Response
HTTP Code: 200 - OK
{
"alternatives": [
{
"message": {
"role": "string",
"text": "string"
},
"status": "string"
}
],
"usage": {
"inputTextTokens": "string",
"completionTokens": "string",
"totalTokens": "string"
},
"modelVersion": "string"
}
Response containing generated text completions.
Field | Description |
---|---|
alternatives[] | object A list of generated completion alternatives. |
alternatives[]. message |
object A message containing the content of the alternative. A message object representing a wrapper over the inputs and outputs of the completion model. |
alternatives[]. message. role |
string The ID of the message sender. Supported roles:
|
alternatives[]. message. text |
string Textual content of the message. |
alternatives[]. status |
string The generation status of the alternative Enum representing the generation status of the alternative.
|
usage | object A set of statistics describing the number of content tokens used by the completion model. An object representing the number of content tokens used by the completion model. |
usage. inputTextTokens |
string (int64) The number of tokens in the textual part of the model input. |
usage. completionTokens |
string (int64) The total number of tokens in the generated completions. |
usage. totalTokens |
string (int64) The total number of tokens, including all input tokens and all generated tokens. |
modelVersion | string The model version changes with each new releases. |