All Products
Search
Document Center

Object Storage Service:Delete a vector bucket (Python SDK V2)

Last Updated:Mar 20, 2026
Warning

Deleting a vector bucket is irreversible. All data in the bucket is permanently removed and cannot be recovered.

Use the Python SDK V2 to delete a vector bucket by calling delete_vector_bucket.

Prerequisites

Before you begin, make sure you have:

  • An existing vector bucket to delete

  • The oss:DeleteVectorBucket permission on your Alibaba Cloud account, or granted to a Resource Access Management (RAM) user or RAM role via a RAM policy or bucket policy

Permissions

By default, your Alibaba Cloud account has full permissions. RAM users and RAM roles have no permissions by default — an administrator must explicitly grant the oss:DeleteVectorBucket action via a RAM policy or bucket policy.

APIActionDescription
DeleteVectorBucketoss:DeleteVectorBucketDeletes a vector bucket

Method definition

delete_vector_bucket(request: DeleteVectorBucketRequest, **kwargs) → DeleteVectorBucketResult

Request parameters

ParameterTypeDescription
requestDeleteVectorBucketRequestThe request object. Set the bucket field to the name of the vector bucket to delete. See DeleteVectorBucketRequest for the full reference.

Return values

TypeDescription
DeleteVectorBucketResultThe result object, containing status_code and request_id. See DeleteVectorBucketResult for the full reference.

For the complete method definition, see delete_vector_bucket.

Examples

The following example loads credentials from environment variables, initializes the vector client, and deletes the specified vector bucket. The core deletion call is:

result = vector_client.delete_vector_bucket(oss_vectors.models.DeleteVectorBucketRequest(
    bucket=args.bucket,
))

Full runnable script:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors

parser = argparse.ArgumentParser(description="vector delete bucket sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS')
parser.add_argument('--account_id', help='The account ID.', required=True)

def main():
    args = parser.parse_args()

    # Load credentials from environment variables
    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    # Initialize the SDK with default configuration
    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    cfg.account_id = args.account_id

    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    vector_client = oss_vectors.Client(cfg)

    result = vector_client.delete_vector_bucket(oss_vectors.models.DeleteVectorBucketRequest(
        bucket=args.bucket,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
    )

if __name__ == "__main__":
    main()

References

For the complete sample, see delete_vector_bucket.py.