Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • 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
© 2025 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
      • Image generation
      • Batch processing
        • Creating an instance
        • Getting instance info
        • Updating an instance
        • Cloning an instance
        • Stopping and starting an instance
        • Managing instance labels
        • Sending a request to an instance
        • Deleting an instance
  • 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 your request
  1. Step-by-step guides
  2. Model Gallery
  3. Using dedicated instances
  4. Sending a request to an instance

Sending a request to an instance

Written by
Yandex Cloud
Updated at November 27, 2025
  • Getting started
  • Send your request

Follow this guide to send a request to an instance in AI Studio.

You can get the request code and the model ID in to the management console.

Getting startedGetting started

To use an example:

SDK
  1. Create a service account and assign the ai.languageModels.user role to it.
  2. Get and save the service account's API key with yc.ai.foundationModels.execute for its scope.

    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.

    Note

    If you are using Windows, we recommend installing the WSL shell first and using it to proceed.

  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. Use the pip package manager to install the ML SDK library:

    pip install yandex-cloud-ml-sdk
    

Send your requestSend your request

SDK
  1. Create a file named test_ml.py and paste the following code into it:

    from yandex_cloud_ml_sdk import YCloudML
    
    sdk = YCloudML(
        folder_id="<folder_ID>", auth="<API_key_or_IAM_token>"
    )
    
    model = sdk.chat.completions("<model_ID>", model_version="<version_ID>")
    model = model.configure(temperature=0.3)
    result = model.run(
        [
            {
                "role": "system",
                "text": "You are a smart assistant"
            },
            {
                "role": "user",
                "text": "Hi! What fields of science did Albert Einstein study?",
            },
        ]
    )
    
    for alternative in result:
        print(result[0].text)
        # Uncomment the next line to get the full response:
        # print(alternative)
    

    Where:

    • folder_id: Yandex Cloud folder ID.
    • auth: Service account API key or IAM token you got earlier for authentication in the API.
    • <model_ID>: ID of the dedicated instance model.
    • model_version: Model version ID.
    • temperature: With a higher temperature, you get more creative and randomized responses from the model. Its values range from 0 to 999999, inclusive.
  2. Run the file you created:

    python3 test_ml.py
    

    Result:

    Albert Einstein was an outstanding physicist, whose works in theoretical physics, theoretical mechanics, and philosophy of science became fundamental. He dedicated his career to studying the fundamentals of the universe, including the theory of relativity, both special and general. Additionally, Albert Einstein studied:\n\n* thermodynamics,\n* statistical mechanics,\n* electromagnetism,\n* quantum theory,\n* special relativity, and more.\n\nHis general relativity works found wide recognition and had a profound influence on the development of modern physics.
    

Was the article helpful?

Previous
Managing instance labels
Next
Deleting an instance
© 2025 Direct Cursus Technology L.L.C.