Create a DashVector client

更新时间:
复制 MD 格式

A DashVector client connects to the DashVector server and provides methods to perform operations on collections.

Prerequisites

Before you begin, make sure you have:

Example

Initialize a client with your API key and cluster endpoint:

PlaceholderDescriptionWhere to find it
YOUR_API_KEYAPI key for authenticationManage API keys
YOUR_CLUSTER_ENDPOINTEndpoint of your DashVector clusterCluster details page in the console
import dashvector

client = dashvector.Client(
    api_key='YOUR_API_KEY',
    endpoint='YOUR_CLUSTER_ENDPOINT',
)

# Verify the connection
if client:
    print("Client created successfully.")

You can also verify the connection by checking the status code:

from dashvector import DashVectorCode

if client.code == DashVectorCode.Success:
    print("Client created successfully.")

Request parameters

ParameterTypeDefault valueDescription
api_keystr--Required. API key for authentication.
endpointstr--Required. Endpoint of the DashVector cluster.
protocolDashVectorProtocolDashVectorProtocol.GRPCOptional. Communication protocol. Valid values: DashVectorProtocol.GRPC and DashVectorProtocol.HTTP.
timeoutfloat10.0Optional. Request timeout in seconds. Set to -1 for no timeout.
Note

Note: DashVectorProtocol.GRPC (the default) provides higher performance than HTTP. Use it unless your environment does not support gRPC.

API signature

dashvector.Client(
    api_key: str,
    endpoint: str,
    protocol: dashvector.DashVectorProtocol = dashvector.DashVectorProtocol.GRPC,
    timeout: float = 10.0
) -> Client

Response parameters

The constructor returns a Client object with the following fields:

FieldTypeDescriptionExample
codeintStatus code. For more information, see Status codes.0
messagestrResponse message.success
request_idstrUnique request ID.19215409-ea66-4db9-8764-26ce2eb5bb99

What's next

Start working with vector data by creating your first collection. See Create a collection.