Authentication with the Yandex Foundation Models API
To work with the Yandex Foundation Models API, you need to get authenticated using your account:
-
Get an IAM token for your Yandex account or federated account.
-
Get the ID of the folder for which your account has the minimal required role to work with the model:
ai.languageModels.user
or higher: To work with YandexGPT APIai.imageGeneration.user
or higher: To work with YandexART
You will need the folder ID to get the model's URI.
-
When accessing YandexART via the API, specify the IAM token in the
Authorization
header of each request:x-folder-id: <folder_ID>
To access Foundation Models, your service account needs at least the minimal required role:
ai.languageModels.user
or higher: To work with YandexGPT APIai.imageGeneration.user
or higher: To work with YandexART
The Foundation Models API supports two methods of authentication with a service account:
-
Using an IAM token:
-
Specify the obtained IAM token in the
Authorization
header in the following format:Authorization: Bearer <IAM_token>
-
With API keys.
API keys do not expire. This means that this authentication method is simpler, but less secure. Use it if you can't automatically request an IAM token.
-
Specify the obtained API key in the
Authorization
header in the following format:Authorization: Api-Key <API_key>
Do not specify the folder ID in request headers, as the service uses the folder in which the service account was created. However, you will need the parent folder ID to get the model's URI.