All Products
Search
Document Center

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

Last Updated:Jun 03, 2026

Call the DeleteVectorIndex operation using the Python SDK V2 to delete a specified vector index. This operation is irreversible, so proceed with caution.

Permissions

An Alibaba Cloud account has all permissions by default. By default, Resource Access Management (RAM) users and RAM roles have no permissions. The Alibaba Cloud account or an administrator must grant the required permissions using a RAM policy overview or a bucket policy.

API

Action

Description

DeleteVectorIndex

oss:DeleteVectorIndex

Delete a vector index.

Method definition

delete_vector_index(request: DeleteVectorIndexRequest, **kwargs) → DeleteVectorIndexResult

Request parameters

Parameter

Type

Description

request

DeleteVectorIndexRequest

The request parameters, including the name of the bucket and the index to delete. For more information, see DeleteVectorIndexRequest

Return values

Type

Description

DeleteVectorIndexResult

The return value. For more information, see DeleteVectorIndexResult

For the complete definition of the delete_vector_index method, see delete_vector_index.

Examples

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

parser = argparse.ArgumentParser(description="vector delete vector index sample")
parser.add_argument('--region', help='The region where the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The endpoint to access OSS.')
parser.add_argument('--index_name', help='The name of the vector index.', required=True)
parser.add_argument('--account_id', help='Your Alibaba Cloud account ID.', required=True)

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

    # Loading credentials values from the environment variables
    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    # Using the SDK's default configuration
    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    cfg.account_id = args.account_id
    cfg.use_internal_endpoint = True  # To access OSS over the public network, set this parameter to False or remove this line.
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    vector_client = oss_vectors.Client(cfg)

    result = vector_client.delete_vector_index(oss_vectors.models.DeleteVectorIndexRequest(
        bucket=args.bucket,
        index_name=args.index_name,
    ))

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

if __name__ == "__main__":
    main()

References

For the complete sample code, see delete_vector_index.py.