The official Rust SDK for Milvus.
The current 2.6.x SDK release line targets Milvus 2.6.x. See CHANGELOG.md for
release-specific features, fixes, and compatibility notes.
The minimum supported Rust version (MSRV) is Rust 1.86.
New applications should use ClientV2, which provides the current request/response-style API.
The original Client API is retained for compatibility with existing applications and is in
maintenance mode.
Create a Rust application and add the SDK and Tokio runtime:
cargo new milvus-quickstart
cd milvus-quickstart
cargo add milvus-sdk-rust
cargo add tokio --features macros,rt-multi-threadThe following program connects to Milvus and checks server health:
use milvus::v2::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
let uri = std::env::var("MILVUS_URI")
.unwrap_or_else(|_| "http://localhost:19530".to_owned());
let token = std::env::var("MILVUS_TOKEN")
.unwrap_or_else(|_| "root:Milvus".to_owned());
let client = ClientV2::new(&ConnectConfig::new().uri(uri).token(token)).await?;
let health = client
.check_health(CheckHealthRequest::builder().build()?)
.await?;
println!("Milvus is healthy: {}", health.is_healthy());
Ok(())
}Run it with:
cargo runThis program expects Milvus at http://localhost:19530 and uses root:Milvus by default. For
another server, set MILVUS_URI and MILVUS_TOKEN. See the
Milvus installation guide for deployment options.
For an independently buildable application that covers collection creation, insertion, loading, search, result handling, and cleanup, follow Tutorial 1: Quick start.
Standalone Cargo projects are available under tutorial. They consume the
published SDK as an application dependency and provide a beginner-to-advanced sequence:
Each tutorial has its own prerequisites, configuration, run command, expected output, and
troubleshooting guidance. Start with the tutorial index for shared
connection settings and the recommended learning path.
On Linux, repository maintainers can start a disposable standalone Milvus server and run every tutorial with:
./scripts/run_tutorials.shAdditional V1 and V2 examples are available under examples. New applications should
start with the V2 examples in examples/v2.
Compile all examples without running them:
cargo build --examplesRun an example by its Cargo target name:
cargo run --example v2_simpleExamples connect to Milvus and may create, modify, or delete resources. Review the selected example and its connection settings before running it.
connection refused: start Milvus or setMILVUS_URIto a reachable endpoint.unauthenticatedorpermission denied: setMILVUS_TOKENto a valid API key orusername:passwordcredential with permission for the requested operation.- load or index timeout: verify that Milvus is healthy and has enough CPU and memory, then retry.
- Docker or port errors from repository scripts: ensure
docker infosucceeds and the required ports are available.
Enable the SDK's tracing feature and add a subscriber to your application:
[dependencies]
milvus-sdk-rust = { version = "2.6", features = ["tracing"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }Initialize the subscriber before creating ClientV2:
use tracing_subscriber::EnvFilter;
fn init_tracing() {
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.init();
}Call init_tracing() at the beginning of main, then select the events to display with
RUST_LOG:
RUST_LOG=milvus_sdk=debug cargo runUse a narrower target when diagnosing one subsystem:
RUST_LOG=milvus_sdk::retry=debug cargo run
RUST_LOG=milvus_sdk::schema_cache=debug cargo run
RUST_LOG=milvus_sdk::polling=debug cargo runThe tracing feature is disabled by default. The SDK does not log credentials, request payloads, filters, or vector data.
See DEVELOPMENT.md for development setup, builds, formatting, mock and server-backed tests, Docker automation, coverage, and protobuf regeneration.