Deleting a dataset
Getting started
To use the examples:
You can start working from the management console right away.
-
Get and save the service account's API key with
yc.ai.foundationModels.executeas the specified 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.
-
Use the pip
package manager to install the ML SDK library:pip install yandex-cloud-ml-sdk
-
Get API authentication credentials as described in Authentication with the Yandex AI Studio API.
-
To use the examples, install cURL
. -
Install gRPCurl
. -
(Optional) Install the jq
JSON stream processor. -
Get an IAM token used for authentication in the API.
The account for which you want to obtain the IAM token must have the
ai.editorrole or higher.Note
The IAM token has a short lifetime up to 12 hours.
Delete a dataset
To delete a dataset:
- In the management console
, select the folder for which your account has theai.playground.userandai.datasets.editorroles or higher. - Go to AI Studio.
- In the AI Studio panel, select
Datasets. - In the list that opens, click
next to the dataset in question and select Delete. - In the window that opens, confirm the deletion.
-
Create a file named
dataset-delete.pyand paste the following code into it:from __future__ import annotations from yandex_cloud_ml_sdk import YCloudML YANDEX_API_KEY = "<API_key>" YANDEX_FOLDER_ID = "<folder_ID>" DATASET_ID = "<dataset_ID>" def main() -> None: sdk = YCloudML( folder_id=YANDEX_FOLDER_ID, auth=YANDEX_API_KEY, ) # Saving the object with the dataset to delete into a variable dataset_to_delete = sdk.datasets.get(dataset_id=DATASET_ID) # Deleting a dataset dataset_to_delete.delete() if __name__ == "__main__": main()Where:
-
YANDEX_API_KEY: Service account API key you got before you started. -
YANDEX_FOLDER_ID: ID of the folder containing the dataset you are deleting. -
DATASET_ID: ID of the dataset to delete. You can view the list of all datasets in the folder using the management console or the API.In ML SDK, you can view the list of datasets in the folder using the
list()method.for dataset in sdk.datasets.list(): print(f"List of existing datasets {dataset=}")
-
-
Run the file you created:
python3 dataset-delete.pyThis will delete the specified dataset.
-
Get the ID of the dataset you want to delete:
grpcurl \ -H "Authorization: Bearer <IAM_token>" \ -d @ \ llm.api.cloud.yandex.net:443 yandex.cloud.ai.dataset.v1.DatasetService/List <<EOM { "folder_id": "<folder_ID>" } EOMWhere:
<IAM_token>: IAM token of the service account you got before you started.<folder_ID>: ID of the folder you are creating the dataset in.
Result:
{ "datasets": [ { "datasetId": "fdsl9hf65509********", "folderId": "b1gt6g8ht345********", "name": "sample-dataset", "status": "READY", "taskType": "TextToTextGeneration", "createdAt": "2025-11-28T08:53:59Z", "updatedAt": "2025-11-28T08:54:38Z", "rows": "354", "sizeBytes": "32314", "createdById": "ajeol2afu1js********", "createdBy": "ajeol2afu1js********" } ] }Save the ID of the dataset you want to delete (the
datasetIdfield value): you will need it to delete the dataset. -
Delete the dataset:
grpcurl \ -H "Authorization: Bearer <IAM_token>" \ -d @ \ llm.api.cloud.yandex.net:443 yandex.cloud.ai.dataset.v1.DatasetService/Delete <<EOM { "dataset_id": "<dataset_ID>" } EOMWhere:
<IAM_token>: IAM token of the service account you got before you started.<dataset_ID>: Dataset ID you saved in the previous step.
The gRPC call will delete the specified dataset.