A DashVector client connects to the DashVector server and provides methods to perform operations on collections.
Prerequisites
Before you begin, make sure you have:
A DashVector cluster (Create a cluster)
An API key (Manage API keys)
The latest DashVector SDK (Install DashVector SDK)
Example
Initialize a client with your API key and cluster endpoint:
| Placeholder | Description | Where to find it |
|---|---|---|
YOUR_API_KEY | API key for authentication | Manage API keys |
YOUR_CLUSTER_ENDPOINT | Endpoint of your DashVector cluster | Cluster 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
api_key | str | -- | Required. API key for authentication. |
endpoint | str | -- | Required. Endpoint of the DashVector cluster. |
protocol | DashVectorProtocol | DashVectorProtocol.GRPC | Optional. Communication protocol. Valid values: DashVectorProtocol.GRPC and DashVectorProtocol.HTTP. |
timeout | float | 10.0 | Optional. 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
) -> ClientResponse parameters
The constructor returns a Client object with the following fields:
| Field | Type | Description | Example |
|---|---|---|---|
code | int | Status code. For more information, see Status codes. | 0 |
message | str | Response message. | success |
request_id | str | Unique request ID. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
What's next
Start working with vector data by creating your first collection. See Create a collection.
该文章对您有帮助吗?