Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex AI Studio
  • Getting started with Model Gallery
    • About Yandex AI Studio
    • Yandex Workflows
    • Quotas and limits
    • Terms and definitions
    • All guides
    • Disabling request logging
    • Getting an API key
        • Estimating prompt size in tokens
        • Sending a request in synchronous mode
        • Sending a series of requests in chat mode
        • Sending a request in background mode
        • Sending an asynchronous request
        • Calling a function from a model
      • Image generation
      • Batch processing
  • Switching from the AI Assistant API to Responses API
  • Compatibility with OpenAI
  • Access management
  • Pricing policy
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Getting started
  • Send a request to the model
  1. Step-by-step guides
  2. Model Gallery
  3. Text generation
  4. Sending a request in synchronous mode

Sending a request in synchronous mode

Written by
Yandex Cloud
Updated at December 29, 2025
  • Getting started
  • Send a request to the model

In text generation tasks that involve short responses or chat mode model operation, the synchronous request mode proves the most effective.

If you are facing a large-scale text generation task, e.g., to process massive documents, the background request mode can be a better option.

Getting startedGetting started

To use an example:

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

  2. Get and save the service account's API key.

    Note

    If you are using Windows, we recommend installing the WSL shell first and then using it to perform other operations.

  3. Install Python 3.10 or higher.

  4. Install Python venv to create isolated virtual environments in Python.

  5. Create a new Python virtual environment and activate it:

    python3 -m venv new-env
    source new-env/bin/activate
    
  6. Install the OpenAI library for Python:

    pip install openai
    

Send a request to the modelSend a request to the model

Python
  1. Create a file named index.py and add the following code to it:

    import openai
    
    YANDEX_CLOUD_MODEL = "yandexgpt-lite"
    
    client = openai.OpenAI(
        api_key=YANDEX_CLOUD_API_KEY,
        base_url="https://rest-assistant.api.cloud.yandex.net/v1",
        project= YANDEX_CLOUD_FOLDER
    )
    
    response = client.responses.create(
        model=f"gpt://{YANDEX_CLOUD_FOLDER}/{YANDEX_CLOUD_MODEL}",
        input="Come up with three off-beat ideas for a travel startup.",
        temperature=0.8,
        max_output_tokens=1500
    )
    
    print(response.output[0].content[0].text)
    
  2. Save authentication data to environment variables:

    export YANDEX_CLOUD_FOLDER=<folder_ID>
    export YANDEX_CLOUD_API_KEY=<API_key>
    
  3. Run the file you created:

    python index.py
    

    Response example:

    1. **Travel search and management platform with astrology factored in.** The service will help travelers choose a destination, trip dates, and activities based on their astrological sign or individual natal chart. This may include recommendations on the best periods for traveling, places that are in tune with your sign's energy, and the choice of cultural and natural attractions that align with your astrological preferences.
    
    2. **Virtual travel guide with augmented reality features.** This is an app or service allowing users to "come across" a virtual guide wherever they are via augmented reality (AR). This guide can share facts if interest about the location, show hidden sightseeing attractions, and suggest routes for your hikes. The user can ask questions and get answers in real time with the AR technology responsible for visualization.
    
    3. **AI-based travel management service.** A platform that relies on AI algorithms to personalize your travels. AI can analyze the user’s preferences, budget, season, etc., and propose optimized routes, including flights, transfers, accommodations, and activities. The service can also propose alternatives if there is a change of schedule or other unforeseen events.
    

See alsoSee also

  • Sending a request in background mode
  • Overview of Yandex AI Studio AI models
  • Examples of working with ML SDK on GitHub

Was the article helpful?

Previous
Estimating prompt size in tokens
Next
Sending a series of requests in chat mode
© 2026 Direct Cursus Technology L.L.C.