Yandex Cloud
Поиск
Связаться с намиПодключиться
  • Документация
  • Блог
  • Все сервисы
  • Статус работы сервисов
    • Популярные
    • Инфраструктура и сеть
    • Платформа данных
    • Контейнеры
    • Инструменты разработчика
    • Бессерверные вычисления
    • Безопасность
    • Мониторинг и управление ресурсами
    • Машинное обучение
    • Бизнес-инструменты
  • Все решения
    • По отраслям
    • По типу задач
    • Экономика платформы
    • Безопасность
    • Техническая поддержка
    • Каталог партнёров
    • Обучение и сертификация
    • Облако для стартапов
    • Облако для крупного бизнеса
    • Центр технологий для общества
    • Облако для интеграторов
    • Поддержка IT-бизнеса
    • Облако для фрилансеров
    • Обучение и сертификация
    • Блог
    • Документация
    • Контент-программа
    • Мероприятия и вебинары
    • Контакты, чаты и сообщества
    • Идеи
    • Истории успеха
    • Тарифы Yandex Cloud
    • Промоакции и free tier
    • Правила тарификации
  • Документация
  • Блог
Проект Яндекса
© 2025 ООО «Яндекс.Облако»
Yandex Foundation Models
    • Обзор
    • Аутентификация в API
        • Overview
          • Overview
          • Completion
  • Yandex Cloud ML SDK
  • Совместимость с OpenAI
  • Управление доступом
  • Правила тарификации
  • Публичные материалы
  • История изменений

В этой статье:

  • HTTP request
  • Body parameters
  • CompletionOptions
  • ReasoningOptions
  • Message
  • ToolCallList
  • ToolCall
  • FunctionCall
  • ToolResultList
  • ToolResult
  • FunctionResult
  • Tool
  • FunctionTool
  • JsonSchema
  • Response
  • Alternative
  • Message
  • ToolCallList
  • ToolCall
  • FunctionCall
  • ToolResultList
  • ToolResult
  • FunctionResult
  • ContentUsage
  • CompletionTokensDetails
  1. Справочники API
  2. Text Generation API (англ.)
  3. REST
  4. TextGeneration
  5. Completion

Foundation Models Text Generation API, REST: TextGeneration.Completion

Статья создана
Yandex Cloud
Улучшена
Tania L.
Обновлена 21 февраля 2025 г.
  • HTTP request
  • Body parameters
  • CompletionOptions
  • ReasoningOptions
  • Message
  • ToolCallList
  • ToolCall
  • FunctionCall
  • ToolResultList
  • ToolResult
  • FunctionResult
  • Tool
  • FunctionTool
  • JsonSchema
  • Response
  • Alternative
  • Message
  • ToolCallList
  • ToolCall
  • FunctionCall
  • ToolResultList
  • ToolResult
  • FunctionResult
  • ContentUsage
  • CompletionTokensDetails

A method for generating text completions in synchronous mode.

HTTP requestHTTP request

POST https://llm.api.cloud.yandex.net/foundationModels/v1/completion

Body parametersBody parameters

{
  "modelUri": "string",
  "completionOptions": {
    "stream": "boolean",
    "temperature": "number",
    "maxTokens": "string",
    "reasoningOptions": {
      "mode": "string"
    }
  },
  "messages": [
    {
      "role": "string",
      // Includes only one of the fields `text`, `toolCallList`, `toolResultList`
      "text": "string",
      "toolCallList": {
        "toolCalls": [
          {
            // Includes only one of the fields `functionCall`
            "functionCall": {
              "name": "string",
              "arguments": "object"
            }
            // end of the list of possible fields
          }
        ]
      },
      "toolResultList": {
        "toolResults": [
          {
            // Includes only one of the fields `functionResult`
            "functionResult": {
              "name": "string",
              // Includes only one of the fields `content`
              "content": "string"
              // end of the list of possible fields
            }
            // end of the list of possible fields
          }
        ]
      }
      // end of the list of possible fields
    }
  ],
  "tools": [
    {
      // Includes only one of the fields `function`
      "function": {
        "name": "string",
        "description": "string",
        "parameters": "object"
      }
      // end of the list of possible fields
    }
  ],
  // Includes only one of the fields `jsonObject`, `jsonSchema`
  "jsonObject": "boolean",
  "jsonSchema": {
    "schema": "object"
  }
  // end of the list of possible fields
}

Request for the service to generate text completion.

Field

Description

modelUri

string

The ID of the model to be used for completion generation.

completionOptions

CompletionOptions

Configuration options for completion generation.

messages[]

Message

A list of messages representing the context for the completion model.

tools[]

Tool

List of tools that are available for the model to invoke during the completion generation.
Note: This parameter is not yet supported and will be ignored if provided.

jsonObject

boolean

When set to true, the model will respond with a valid JSON object.
Be sure to explicitly ask the model for JSON.
Otherwise, it may generate excessive whitespace and run indefinitely until it reaches the token limit.

Includes only one of the fields jsonObject, jsonSchema.

Specifies the format of the model's response.

jsonSchema

JsonSchema

Enforces a specific JSON structure for the model's response based on a provided schema.

Includes only one of the fields jsonObject, jsonSchema.

Specifies the format of the model's response.

CompletionOptionsCompletionOptions

Defines the options for completion generation.

Field

Description

stream

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).
Lower values produce more straightforward responses while higher values lead to increased creativity and randomness.
Default temperature: 0.3

maxTokens

string (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.

reasoningOptions

ReasoningOptions

Configures reasoning capabilities for the model, allowing it to perform internal reasoning before responding.

ReasoningOptionsReasoningOptions

Represents reasoning options that enable the model's ability to perform internal reasoning before generating a response.

Field

Description

mode

enum (ReasoningMode)

Specifies the reasoning mode to be used.

  • REASONING_MODE_UNSPECIFIED: Unspecified reasoning mode.
  • DISABLED: Disables reasoning. The model will generate a response without performing any internal reasoning.
  • ENABLED_HIDDEN: Enables reasoning in a hidden manner without exposing the reasoning steps to the user.

MessageMessage

A message object representing a wrapper over the inputs and outputs of the completion model.

Field

Description

role

string

The ID of the message sender. Supported roles:

  • system: Special role used to define the behaviour of the completion model.
  • assistant: A role used by the model to generate responses.
  • user: A role used by the user to describe requests to the model.

text

string

Textual content of the message.

Includes only one of the fields text, toolCallList, toolResultList.

Message content.

toolCallList

ToolCallList

List of tool calls made by the model as part of the response generation.

Includes only one of the fields text, toolCallList, toolResultList.

Message content.

toolResultList

ToolResultList

List of tool results returned from external tools that were invoked by the model.

Includes only one of the fields text, toolCallList, toolResultList.

Message content.

ToolCallListToolCallList

Represents a list of tool calls.

Field

Description

toolCalls[]

ToolCall

A list of tool calls to be executed.

ToolCallToolCall

Represents a call to a tool.

Field

Description

functionCall

FunctionCall

Represents a call to a function.

Includes only one of the fields functionCall.

FunctionCallFunctionCall

Represents the invocation of a function with specific arguments.

Field

Description

name

string

The name of the function being called.

arguments

object

The structured arguments passed to the function.
These arguments must adhere to the JSON Schema defined in the corresponding function's parameters.

ToolResultListToolResultList

Represents a list of tool results.

Field

Description

toolResults[]

ToolResult

A list of tool results.

ToolResultToolResult

Represents the result of a tool call.

Field

Description

functionResult

FunctionResult

Represents the result of a function call.

Includes only one of the fields functionResult.

FunctionResultFunctionResult

Represents the result of a function call.

Field

Description

name

string

The name of the function that was executed.

content

string

The result of the function call, represented as a string.
This field can be used to store the output of the function.

Includes only one of the fields content.

ToolTool

Represents a tool that can be invoked during completion generation.

Field

Description

function

FunctionTool

Represents a function that can be called.

Includes only one of the fields function.

FunctionToolFunctionTool

Represents a function tool that can be invoked during completion generation.

Field

Description

name

string

The name of the function.

description

string

A description of the function's purpose or behavior.

parameters

object

A JSON Schema that defines the expected parameters for the function.
The schema should describe the required fields, their types, and any constraints or default values.

JsonSchemaJsonSchema

Represents the expected structure of the model's response using a JSON Schema.

Field

Description

schema

object

The JSON Schema that the model's output must conform to.

ResponseResponse

HTTP Code: 200 - OK

{
  "alternatives": [
    {
      "message": {
        "role": "string",
        // Includes only one of the fields `text`, `toolCallList`, `toolResultList`
        "text": "string",
        "toolCallList": {
          "toolCalls": [
            {
              // Includes only one of the fields `functionCall`
              "functionCall": {
                "name": "string",
                "arguments": "object"
              }
              // end of the list of possible fields
            }
          ]
        },
        "toolResultList": {
          "toolResults": [
            {
              // Includes only one of the fields `functionResult`
              "functionResult": {
                "name": "string",
                // Includes only one of the fields `content`
                "content": "string"
                // end of the list of possible fields
              }
              // end of the list of possible fields
            }
          ]
        }
        // end of the list of possible fields
      },
      "status": "string"
    }
  ],
  "usage": {
    "inputTextTokens": "string",
    "completionTokens": "string",
    "totalTokens": "string",
    "completionTokensDetails": {
      "reasoningTokens": "string"
    }
  },
  "modelVersion": "string"
}

Response containing generated text completions.

Field

Description

alternatives[]

Alternative

A list of generated completion alternatives.

usage

ContentUsage

A set of statistics describing the number of content tokens used by the completion model.

modelVersion

string

The model version changes with each new releases.

AlternativeAlternative

Represents a generated completion alternative, including its content and generation status.

Field

Description

message

Message

A message with the content of the alternative.

status

enum (AlternativeStatus)

The generation status of the alternative.

  • ALTERNATIVE_STATUS_UNSPECIFIED: Unspecified generation status.
  • ALTERNATIVE_STATUS_PARTIAL: Partially generated alternative.
  • ALTERNATIVE_STATUS_TRUNCATED_FINAL: Incomplete final alternative resulting from reaching the maximum allowed number of tokens.
  • ALTERNATIVE_STATUS_FINAL: Final alternative generated without running into any limits.
  • ALTERNATIVE_STATUS_CONTENT_FILTER: Generation was stopped due to the discovery of potentially sensitive content in the prompt or generated response.
    To fix, modify the prompt and restart generation.
  • ALTERNATIVE_STATUS_TOOL_CALLS: Tools were invoked during the completion generation.

MessageMessage

A message object representing a wrapper over the inputs and outputs of the completion model.

Field

Description

role

string

The ID of the message sender. Supported roles:

  • system: Special role used to define the behaviour of the completion model.
  • assistant: A role used by the model to generate responses.
  • user: A role used by the user to describe requests to the model.

text

string

Textual content of the message.

Includes only one of the fields text, toolCallList, toolResultList.

Message content.

toolCallList

ToolCallList

List of tool calls made by the model as part of the response generation.

Includes only one of the fields text, toolCallList, toolResultList.

Message content.

toolResultList

ToolResultList

List of tool results returned from external tools that were invoked by the model.

Includes only one of the fields text, toolCallList, toolResultList.

Message content.

ToolCallListToolCallList

Represents a list of tool calls.

Field

Description

toolCalls[]

ToolCall

A list of tool calls to be executed.

ToolCallToolCall

Represents a call to a tool.

Field

Description

functionCall

FunctionCall

Represents a call to a function.

Includes only one of the fields functionCall.

FunctionCallFunctionCall

Represents the invocation of a function with specific arguments.

Field

Description

name

string

The name of the function being called.

arguments

object

The structured arguments passed to the function.
These arguments must adhere to the JSON Schema defined in the corresponding function's parameters.

ToolResultListToolResultList

Represents a list of tool results.

Field

Description

toolResults[]

ToolResult

A list of tool results.

ToolResultToolResult

Represents the result of a tool call.

Field

Description

functionResult

FunctionResult

Represents the result of a function call.

Includes only one of the fields functionResult.

FunctionResultFunctionResult

Represents the result of a function call.

Field

Description

name

string

The name of the function that was executed.

content

string

The result of the function call, represented as a string.
This field can be used to store the output of the function.

Includes only one of the fields content.

ContentUsageContentUsage

An object representing the number of content tokens used by the completion model.

Field

Description

inputTextTokens

string (int64)

The number of tokens in the textual part of the model input.

completionTokens

string (int64)

The number of tokens in the generated completion.

totalTokens

string (int64)

The total number of tokens, including all input tokens and all generated tokens.

completionTokensDetails

CompletionTokensDetails

Provides additional information about how the completion tokens were utilized.

CompletionTokensDetailsCompletionTokensDetails

Provides additional information about how the completion tokens were utilized.

Field

Description

reasoningTokens

string (int64)

The number of tokens used specifically for internal reasoning performed by the model.

Была ли статья полезна?

Предыдущая
Overview
Следующая
Overview
Проект Яндекса
© 2025 ООО «Яндекс.Облако»