Getting a list of AI Studio models

You can use the Models API to get a list of all models available in your folder.

To use the example, you will need a service account with the ai.languageModels.user role and an API key with the yc.ai.foundationModels.execute scope. The API key you can create in AI Studio has these permissions. Refer to the Getting started section for an example of how to configure your runtime environment.

import openai
        
        YANDEX_API_KEY = "<API_key>"
        YANDEX_FOLDER_ID = "<folder_ID>"
        
        client = openai.OpenAI(
            api_key=YANDEX_API_KEY,
            base_url="https://ai.api.cloud.yandex.net/v1",
            project=YANDEX_FOLDER_ID,
        )
        
        models = client.models.list()
        print(models.data)
        

Where:

  • YANDEX_API_KEY: API key for access to AI Studio.
  • YANDEX_FOLDER_ID: Service account folder ID.

Result example:

[Model(id='emb://b1gt6g8ht345********/text-embeddings/latest@tamrste7cghc5j6m1a21v', created=0, object='model', owned_by='Yandex'),
        Model(id='gpt://b1gt6g8ht345********/aliceai-llm/latest', created=0, object='model', owned_by='Yandex'),
        ...
        Model(id='gpt://b1gt6g8ht345********/yandexgpt/rc', created=0, object='model', owned_by='Yandex')]
        
import OpenAI from "openai";
        
        const YANDEX_API_KEY = "<API_key>";
        const YANDEX_FOLDER_ID = "<folder_ID>";
        
        const client = new OpenAI({
          apiKey: YANDEX_API_KEY,
          baseURL: "https://ai.api.cloud.yandex.net/v1",
          project: YANDEX_FOLDER_ID,
        });
        
        const models = await client.models.list();
        
        for await (const model of models) {
          console.log(model.id);
        }
        

Where:

  • YANDEX_API_KEY: API key for access to AI Studio.
  • YANDEX_FOLDER_ID: Service account folder ID.

Result example:

emb://b1gt6g8ht345********/text-embeddings/latest@tamrste7cghc5j6m1a21v
        gpt://b1gt6g8ht345********/aliceai-llm/latest
        ...
        gpt://b1gt6g8ht345********/yandexgpt/rc
        
package main
        
        import (
          "context"
          "fmt"
          "os"
        
          "github.com/openai/openai-go"
          "github.com/openai/openai-go/option"
        )
        
        var (
          YANDEX_API_KEY   = os.Getenv("YANDEX_API_KEY")
          YANDEX_FOLDER_ID = os.Getenv("YANDEX_FOLDER_ID")
        )
        
        func main() {
          if YANDEX_API_KEY == "" {
            fmt.Println("Error: the YANDEX_API_KEY environment variable is not set")
            os.Exit(1)
          }
          if YANDEX_FOLDER_ID == "" {
            fmt.Println("Error: the YANDEX_FOLDER_ID environment variable is not set")
            os.Exit(1)
          }
        
          client := openai.NewClient(
            option.WithAPIKey(YANDEX_API_KEY),
            option.WithBaseURL("https://ai.api.cloud.yandex.net/v1"),
            option.WithHeader("x-folder-id", YANDEX_FOLDER_ID),
          )
        
          models := client.Models.ListAutoPaging(context.Background())
        
          for models.Next() {
            model := models.Current()
            fmt.Printf("%+v\n", model)
          }
        
          if err := models.Err(); err != nil {
            fmt.Printf("Error: %v\n", err)
            os.Exit(1)
          }
        }
        

Where:

  • YANDEX_API_KEY: API key for access to AI Studio.
  • YANDEX_FOLDER_ID: Service account folder ID.

Result example:

[Model(id='emb://b1gt6g8ht345********/text-embeddings/latest@tamrste7cghc5j6m1a21v', created=0, object='model', owned_by='Yandex'),
        Model(id='gpt://b1gt6g8ht345********/aliceai-llm/latest', created=0, object='model', owned_by='Yandex'),
        ...
        Model(id='gpt://b1gt6g8ht345********/yandexgpt/rc', created=0, object='model', owned_by='Yandex')]
        
curl https://ai.api.cloud.yandex.net/v1/models \
          --header "Authorization: Api-Key <API_key>" \
          --header "x-project: <folder_ID>"
        

Where:

  • <API_key>: API key for access to AI Studio.
  • <folder_ID>: Service account folder ID.

Result example:

{
          "object": "list",
          "data": [
            {
              "id": "emb://b1gt6g8ht345********/text-embeddings/latest@tamrste7cghc5j6m1a21v",
              "object": "model",
              "created": 0,
              "owned_by": "Yandex"
            },
            {
              "id": "gpt://b1gt6g8ht345********/yandexgpt/rc",
              "object": "model",
              "created": 0,
              "owned_by": "Yandex"
            }
          ]
        }
        
from yandex_ai_studio_sdk import AIStudio
        
        YANDEX_API_KEY = "<API_key>"
        YANDEX_FOLDER_ID = "<folder_ID>"
        
        sdk = AIStudio(
            folder_id=YANDEX_FOLDER_ID,
            auth=YANDEX_API_KEY,
        )
        
        models = sdk.chat.completions.list()
        
        for model in models:
            print(model.uri)
        

Where:

  • YANDEX_API_KEY: API key for access to AI Studio.
  • YANDEX_FOLDER_ID: Service account folder ID.

Result example:

gpt://b1gt6g8ht345********/aliceai-llm/latest
        gpt://b1gt6g8ht345********/yandexgpt/latest
        ...
        gpt://b1gt6g8ht345********/qwen3-235b-a22b-fp8/latest
        

See also