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
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
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 an image
  1. Getting started
  2. Getting started with YandexART

Getting started with YandexART

Written by
Yandex Cloud
Updated at April 21, 2025
  • Getting started
  • Generate an image

In this section, you will learn how to use the YandexART neural network to generate images.

In the management console, 10 free prompts per day are available to new users without a billing account. To access the API and increase usage quotas, link your billing account to the cloud.

Getting startedGetting 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.imageGeneration.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 examples of requests using the API, install:

  • cURL to send API requests.
  • jq utility to work with JSON files.

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

  1. Get an IAM token for your Yandex account or federated account.

  2. Get the ID of the folder for which your account has the ai.imageGeneration.user role or higher. You will need the folder ID to get the model URI.

  3. When accessing YandexART via the API, specify the IAM token in the Authorization header of each request:

    x-folder-id: <folder_ID>
    

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

Generate an imageGenerate an image

Note

YandexART logs user prompts to generate better responses. 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.imageGeneration.user role or higher.
  2. From the list of services, select Foundation Models.
  3. In the left-hand panel, select YandexART.
  4. In the input field, describe the image you want to generate. You should use vivid and detailed descriptions, specify styles if you want your image styled in a certain way.
  5. Leave the seed parameter random or specify any value.
  6. Click Generate. Generating an image takes some time The output will appear on the left side of the screen.

The code in the example waits until the model completes the request, then saves the result to the result variable before saving the generated image on the disk to the image.jpeg file in the current directory. For additional methods of working with the YandexART model, see Generating an image using YandexART.

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

    #!/usr/bin/env python3
    
    from __future__ import annotations
    import pathlib
    from yandex_cloud_ml_sdk import YCloudML
    
    message = "a pattern of pastel colored succulents of multiple varieties, hd full wallpaper, sharp focus, many intricate details, picture depth, top view"
    
    
    def main():
        sdk = YCloudML(
            folder_id="<folder_ID>",
            auth="<API_key>",
        )
    
        model = sdk.models.image_generation("yandex-art")
    
        # configuring model
        model = model.configure(width_ratio=2, height_ratio=1, seed=1863)
    
        path = pathlib.Path("./image.jpeg")
        operation = model.run_deferred(message)
        result = operation.wait()
        path.write_bytes(result.image_bytes)
    
    
    if __name__ == "__main__":
        main()
    

    Where:

    • message: Variable containing the text of the image generation request.

      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.

    • <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 model, see Accessing a model.

  2. Run the created file:

    python3 generate-image.py
    

    Result:

    succulent

  1. Create a file with the request body, e.g., prompt.json:

    {
    "modelUri": "art://<folder_ID>/yandex-art/latest",
    "generationOptions": {
      "seed": "1863",
      "aspectRatio": {
         "widthRatio": "2",
         "heightRatio": "1"
       }
    },
    "messages": [
      {
        "weight": "1",
        "text": "a pattern of pastel colored succulents of multiple varieties, hd full wallpaper, sharp focus, many intricate details, picture depth, top view"
      }
    ]
    }
    

    Where:

    • modelUri: YandexART model ID which contains a Yandex Cloud folder ID.
    • seed: Generation seed.
    • text: Text description of the image to use for generation.
    • weight: Text description weight. If a request contains more than one description, their individual impact will be calculated based on weight, with the sum of all weights equal to 1.
    • aspectRatio: (Optional) Aspect ratio of the generated image:
      • widthRatio: Width (default value: 1).
      • heightRatio: Height (default value: 1).
  2. To send a request to the neural network using the ImageGenerationAsync.generate method, run the following command:

    curl \
      --request POST \
      --header "Authorization: Bearer <IAM_token_value>" \
      --data "@prompt.json" \
      "https://llm.api.cloud.yandex.net/foundationModels/v1/imageGenerationAsync"
    

    Where:

    • <IAM_token_value>: IAM token you got for your account.
    • prompt.json: JSON file with request parameters.

    The service will respond with your request ID:

    {
    "id":"fbveu1sntj**********","description":"","createdAt":null,"createdBy":"","modifiedAt":null,"done":false,"metadata":null}
    
  3. Generating an image takes some time. Wait for 10 seconds and send your request to get the generation result. When the image is ready, you will get the result in a Base64-encoded file named image.jpeg.

    curl \
      --request GET \
      --header "Authorization: Bearer <IAM_token_value>" \
      https://llm.api.cloud.yandex.net:443/operations/<request_ID> | \
      jq -r '.response | .image' | base64 -d > image.jpeg
    

    Where:

    • <IAM_token_value>: IAM token you obtained when getting started.
    • <request_ID>: id field value obtained in response to the generation request.

    Result:

    succulent

What's nextWhat's next

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

Was the article helpful?

Previous
Getting started with YandexGPT
Next
All guides
© 2025 Direct Cursus Technology L.L.C.