Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Foundation Models
    • Getting started with YandexGPT
    • Getting started with YandexART
  • Yandex Cloud ML SDK
  • Compatibility with OpenAI
  • Access management
  • Pricing policy
  • Public materials
  • Release notes

In this article:

  • Getting started
  • Generate the text
  1. Getting started
  2. Getting started with YandexGPT

Getting started with YandexGPT Lite and YandexGPT Pro

Written by
Yandex Cloud
Updated at April 21, 2025
  • Getting started
  • Generate the text

In this section, you will learn how to use the YandexGPT model to generate texts in synchronous mode without adding context. For other examples, see Guides on how to use Yandex Foundation Models

The management console provides a quick and easy way for new users without a billing account to try out the model with 10 free prompts per hour. To access the API and increase usage quotas, link your billing account to your cloud.

For information about Yandex Foundation Models pricing, see Yandex Foundation Models pricing policy.

Getting started

To get started in Yandex Cloud:

  1. Log in to the management console. If not signed up yet, navigate to the management console and follow the on-screen instructions.
  2. In Yandex Cloud Billing, make sure you have a billing account linked and its status is ACTIVE or TRIAL_ACTIVE. If you do not have a billing account yet, create one.
  3. If you do not have a folder yet, create one.
Management console
SDK
API

You can start working from the management console right away.

To use the examples of requests using SDK:

  1. Create a service account and assign the ai.languageModels.user role to it.

  2. Get the service account API key and save it.

    The following examples use API key authentication. Yandex Cloud ML SDK also supports IAM token and OAuth token authentication. For more information, see Authentication in Yandex Cloud ML SDK.

  3. Use the pip package manager to install the ML SDK library:

    pip install yandex-cloud-ml-sdk
    

To run sample requests using the API, install cURL.

To work with the YandexGPT API, you need to get authenticated using your account:

  1. Get an IAM token: see the guide for a Yandex account or federated account.

  2. Get the ID of the folder for which your account has the ai.languageModels.user role or higher.

  3. When accessing YandexGPT Lite or YandexGPT Pro via the API, provide the received parameters:

    • In the request file, specify the folder ID in the modelUri parameter.
    • In the request, specify the IAM token in the Authorization header.
    Authorization: Bearer <IAM_token>
    

For information about other API authentication methods, see Authentication with the Yandex Foundation Models API.

Generate the text

Note

The Foundation Models API logs the users' prompts to improve the quality of responses it generates. Do not use sensitive information and personal data in your prompts.

Management console
SDK
API
  1. In the management console, select the folder for which your account has the ai.languageModels.user role or higher.

  2. From the list of services, select Foundation Models.

  3. In the left-hand panel, select YandexGPT Prompt mode.

    screen01

  4. In the Temperature field, enter a value between 0 and 1 for the model's response variability. With a higher value, you get a less deterministic result.

  5. Describe the request context under Instructions.

  6. Describe your request to the model under Request.

  7. Click View answer. The answer will be shown on the right part of the screen.

    screen02

  1. Create a file named generate-text.py and paste the following code into it:

    #!/usr/bin/env python3
    
    from __future__ import annotations
    from yandex_cloud_ml_sdk import YCloudML
    
    messages = [
        {
            "role": "system",
            "text": "Find errors in the text and correct them",
        },
        {
            "role": "user",
            "text": """Laminate flooring is sutiable for instalation in the kitchen or in a child's 
    room. It withsatnds moisturre and mechanical dammage thanks to 
    a 0.2 mm thick proctive layer of melamine films and 
    a wax-treated interlocking system.""",
        },
    ]
    
    
    def main():
        sdk = YCloudML(
            folder_id="<folder_ID>",
            auth="<API_key>",
        )
    
        result = (
            sdk.models.completions("yandexgpt").configure(temperature=0.5).run(messages)
        )
    
        for alternative in result:
            print(alternative)
    
    
    if __name__ == "__main__":
        main()
    

    Where:

    Note

    As input data for a request, Yandex Cloud ML SDK can accept a string, a dictionary, an object of the TextMessage class, or an array containing any combination of these data types. For more information, see Yandex Cloud ML SDK usage.

    • messages: List of messages that set the context for the model:

      • role: Message sender's role:

        • user: Used for sending user messages to the model.
        • system: Used to set the query context and define the model's behavior.
        • assistant: Used for responses generated by the model. In chat mode, the model's responses tagged with the assistant role are included in the message to save the conversation context. Do not send user messages with this role.
      • text: Message text.

    • <folder_ID>: ID of the folder in which the service account was created.

    • <API_key>: Service account API key you got earlier required for authentication in the API.

      The following examples use API key authentication. Yandex Cloud ML SDK also supports IAM token and OAuth token authentication. For more information, see Authentication in Yandex Cloud ML SDK.

    For more information about accessing a specific model version, see Accessing models.

  2. Run the created file:

    python3 generate-text.py
    

    Result:

    Alternative(role='assistant', text='Laminate flooring is suitable for installation in the kitchen or in a child's room. It withstands moisture and mechanical damage thanks to a 0.2 mm thick protective layer of melamine films and a wax-treated interlocking system.', status=<AlternativeStatus.FINAL: 3>)
    
  1. Create a file with the request body, e.g., prompt.json:

    {
      "modelUri": "gpt://<folder_ID>/yandexgpt",
      "completionOptions": {
        "stream": false,
        "temperature": 0.6,
        "maxTokens": "2000",
        "reasoningOptions": {
          "mode": "DISABLED"
        }
      },
      "messages": [
        {
          "role": "system",
          "text": "Find errors in the text and correct them."
        },
        {
          "role": "user",
          "text": "Laminate flooring is sutiable for instalation in the kitchen or in a child's room. It withsatnds moisturre and mechanical dammage thanks to a 0.2 mm thick proctive layer of melamine films and a wax-treated interlocking systme."
        }
      ]
    }
    

    Where:

    • modelUri: ID of the model that will be used to generate the response. The parameter contains the Yandex Cloud folder ID or the tuned model's ID.

    • completionOptions: Request configuration options:

      • stream: Enables streaming of partially generated text. It can either be true or false.

      • temperature: With a higher temperature, you get more creative and randomized responses from the model. Its values range from 0 to 1, inclusive. The default value is 0.3.

      • maxTokens: Sets a limit on the model's output in tokens. The maximum number of tokens per generation depends on the model. For more information, see Quotas and limits in Yandex Foundation Models.

      • reasoningOptions.mode: Reasoning mode parameters. This is an optional parameter. The default value is DISABLED. The possible values are:

        • DISABLED: Reasoning mode is disabled.
        • ENABLED_HIDDEN: Reasoning mode is enabled. The model will decide by itself whether or not to use this mode for each particular request.
    • messages: List of messages that set the context for the model:

      • role: Message sender's role:

        • user: Used for sending user messages to the model.
        • system: Used to set the query context and define the model's behavior.
        • assistant: Used for responses generated by the model. In chat mode, the model's responses tagged with the assistant role are included in the message to save the conversation context. Do not send user messages with this role.
      • text: Message text.

  2. Use the completion method to send a request to the neural network in the following command:

    export FOLDER_ID=<folder_ID>
    export IAM_TOKEN=<IAM_token>
    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data "@prompt.json" \
      "https://llm.api.cloud.yandex.net/foundationModels/v1/completion"
    

    Where:

    • FOLDER_ID: ID of the folder for which your account has the ai.languageModels.user role or higher.
    • IAM_TOKEN: IAM token you got before you started.

    The service will respond with the generated text:

    {
      "result": {
        "alternatives": [
          {
            "message": {
              "role": "assistant",
              "text": "Laminate flooring is suitable for installation in the kitchen or in a child's room. It withstands moisture and mechanical damage thanks to a 0.2 mm thick protective layer of melamine films and a wax-treated interlocking system."
            },
            "status": "ALTERNATIVE_STATUS_TRUNCATED_FINAL"
          }
        ],
        "usage": {
          "inputTextTokens": "67",
          "completionTokens": "50",
          "totalTokens": "117"
        },
        "modelVersion": "06.12.2023"
      }
    }
    

What's next

  • Learn more about the service
  • Learn about API authentication methods

Was the article helpful?

Next
Getting started with YandexART
Yandex project
© 2025 Yandex.Cloud LLC