Foundation Models Text Generation API, REST: Tokenizer.tokenizeCompletion
RPC method for tokenizing content of CompletionRequest
HTTP request
POST https://llm.api.cloud.yandex.net/foundationModels/v1/tokenizeCompletion
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
{
"tokens": [
{
"id": "string",
"text": "string",
"special": true
}
],
"modelVersion": "string"
}
Response containing tokenized content from request.
Field | Description |
---|---|
tokens[] | object A list of tokens obtained from tokenization. |
tokens[]. id |
string (int64) An internal token identifier. |
tokens[]. text |
string The textual representation of the token. |
tokens[]. special |
boolean (boolean) Indicates whether the token is special or not. Special tokens may define the model's behavior and are not visible to users. |
modelVersion | string Model version (changes with model releases). |