Skip to main content

Python SDK Reference

MilvusClient provides a simple and easy-to-use alternative to the legacy ORM approach. It adopts a purely functional approach to simplify interactions with the server. Each MilvusClient establishes a gRPC connection to the server you specified. To set up multiple connections, you can create multiple MilvusClient instances.

Install & Update

You can run the following command in your terminal to install the latest PyMilvus or update your PyMilvus to this version.

pip install --upgrade pymilvus

After the installation, you can check the pymilvus version by running the following

from pymilvus import __version__

print(__version__)

Connect to Cluster

from pymilvus import MilvusClient

# Authentication enabled with a cluster user
client = MilvusClient(
uri="https://inxx-xxxxxxxxxxxx.api.gcp-us-west1.zillizcloud.com:19530",
token="user:password", # replace this with your token
)
Note

When performing operations with PyMilvus, you can use either of the following methods to authenticate:

  • Using an API key

    To obtain an API key, follow the instructions in the API keys.

  • Using a cluster token

    To obtain a cluster token, use a colon (:) to join the username and password of the target cluster, like username:password. Note that this is the only valid authentication method for BYOC clusters.

What's New

In this version, PyMilvus adds a MilvusClient module that incorporates several functional methods, aligning its functionality overall with that of the legacy ORM module.

Examples

In addition to the documents, you can also refer to the example sets in our GitHub repo.