Skip to main content

Rust

The Ahnlich Rust client library is a Rust crate that allows you to interact with Ahnlich DB and Ahnlich AI.


id: client-rust

title: Rust SDK (๐Ÿฆ€)

sidebar_label: Rust

description: Official Rust client library to integrate with Ahnlich DB (exact vector search) and AI (semantic embeddings) services.


๐Ÿฆ€ Ahnlich Rust SDKโ€‹

The official Rust client to interface with ahnlichโ€‘db (exact similarity search) and ahnlichโ€‘ai (semantic similarity) over gRPC.

See full API docs and examples at docs.rs โ€“ ahnlich_client_rs

oaicite:0

๐Ÿš€ Connecting to DB / AI Servicesโ€‹

Both services expect:

  • ahnlich-db should be accessible (default: 127.0.0.1:1369)
  • ahnlich-ai should be separately reachable (default: 127.0.0.1:1370 or as configured)

The SDK supports optional W3C trace context via an Option<String> trace_id in all calls.

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let tracing_id: Option<String> = None;

// โœ”๏ธ DB client:
let db_client = ahnlich_client_rs::db::DbClient::new("127.0.0.1:1369".to_string()).await?;
db_client.ping(tracing_id.clone()).await?;

// โœ”๏ธ AI client:
let ai_client = ahnlich_client_rs::ai::AIClient::new("127.0.0.1:1369".to_string()).await?;
ai_client.ping(tracing_id.clone()).await?;

Ok(())
}

๐Ÿง  Best Practices Always match vector/query dimension to the storeโ€™s declared dimension (e.g. 128 or 768).

Use DbClient::pipeline() or AIClient::pipeline() if you require ordered batched operations with predictable response order.

Metadata predicates are fast and flexible filtering toolsโ€”even if predicates aren't pre-indexed.

AI Stores automatically handle embedding; no need to compute embeddings manually for raw input.

Installationโ€‹

Installation and Usage

Referenceโ€‹

Reference