All Products
Search
Document Center

Object Storage Service:Get vector index information (Python SDK V2)

Last Updated:Jun 03, 2026

Use the Python SDK V2 to call the GetVectorIndex operation to retrieve information about a specified vector index.

Permissions

Alibaba Cloud accounts have full permissions by default. RAM users and RAM roles require explicit authorization through a RAM policy or a bucket policy.

API

Action

Description

GetVectorIndex

oss:GetVectorIndex

Retrieves vector index information.

Method definition

get_vector_index(request: GetVectorIndexRequest, **kwargs) → GetVectorIndexResult

Request parameters

Parameter

Type

Description

request

GetVectorIndexRequest

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

Return values

Type

Description

GetVectorIndexResult

The return value, which contains the detailed information about the vector index. For more information, see GetVectorIndexResult.

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

Sample code

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

parser = argparse.ArgumentParser(description="vector get vector index sample")
parser.add_argument('--region', help='The region of the bucket.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The domain name for accessing OSS.')
parser.add_argument('--index_name', help='The name of the vector index.', required=True)
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()

    # Use 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 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.get_vector_index(oss_vectors.models.GetVectorIndexRequest(
        bucket=args.bucket,
        index_name=args.index_name,
    ))

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

    if result.index:
        print(f'index name: {result.index}')

if __name__ == "__main__":
    main()

References

For the complete sample code, see get_vector_index.py.