SDKs overview
Qdrant provides client libraries (SDKs) to facilitate interaction with its vector database, abstracting the direct HTTP API calls. These SDKs are designed to streamline common operations such as creating collections, inserting vectors, performing similarity searches, and managing indexes. The availability of SDKs across multiple programming languages allows developers to integrate Qdrant into a variety of application environments, from backend services to data science workflows. Both official and community-contributed libraries are available, catering to different development preferences and project requirements. The official SDKs are developed and maintained by the Qdrant team, ensuring compatibility with the latest features and API versions, as detailed in the Qdrant HTTP API reference.
Using an SDK often reduces boilerplate code and handles aspects like request serialization, response deserialization, and error handling, which would otherwise need to be managed manually when interacting with a RESTful API. This approach contributes to a more efficient development cycle and reduces the potential for integration errors. For example, a developer using the Python SDK can interact with Qdrant using familiar Python data structures and methods, rather than constructing HTTP requests with JSON payloads directly.
Official SDKs by language
Qdrant maintains official client libraries for several widely used programming languages. These SDKs are the recommended method for integrating Qdrant into applications due to their direct support from the Qdrant development team and adherence to the database's evolving API. Each SDK aims to provide an idiomatic interface for its respective language, making it easier for developers to adopt and utilize Qdrant's capabilities.
| Language | Package Name | Installation Command (Example) | Maturity |
|---|---|---|---|
| Python | qdrant-client |
pip install qdrant-client |
Stable |
| Go | github.com/qdrant/go-client/qdrant |
go get github.com/qdrant/go-client/qdrant |
Stable |
| Rust | qdrant-client |
cargo add qdrant-client |
Stable |
| TypeScript | @qdrant/js-client-rest |
npm install @qdrant/js-client-rest |
Stable |
| Java | io.qdrant:client |
Maven: Add dependency to pom.xml |
Stable |
| C# | Qdrant.Client |
dotnet add package Qdrant.Client |
Stable |
Each official SDK provides comprehensive functionality, including collection management, point operations (upsert, retrieve, delete), search queries with various filtering options, and snapshot management. Developers can find detailed API documentation and usage examples for each SDK within the Qdrant documentation, ensuring they have the necessary resources to implement their vector search solutions effectively. The stability indicated reflects the general readiness for production use, with ongoing updates and maintenance from the Qdrant team.
Installation
Installing Qdrant SDKs typically involves using the package manager specific to the chosen programming language. The following provides common installation instructions for the official client libraries.
Python
To install the Qdrant Python client, use pip:
pip install qdrant-client
This command fetches the latest stable version of the Python client from the Python Package Index (PyPI). Developers often use virtual environments to manage dependencies, preventing conflicts between projects. For example, creating a virtual environment with python -m venv .venv and activating it with source .venv/bin/activate (Linux/macOS) or .venv\Scripts\activate (Windows PowerShell) before installation is a common practice.
Go
For Go projects, use go get to add the Qdrant client:
go get github.com/qdrant/go-client/qdrant
After running this command, Go modules will automatically manage the dependency. You can then import the client package in your Go source files using import "github.com/qdrant/go-client/qdrant".
Rust
Add the Qdrant client to your Rust project's Cargo.toml file or use cargo add:
cargo add qdrant-client
This command updates your Cargo.toml to include qdrant-client = "*" (or the latest version), and cargo build will then download and compile the dependency. Rust's robust type system and ownership model provide compile-time guarantees that can help prevent common runtime errors in concurrent applications often seen in vector database interactions.
TypeScript / JavaScript
For Node.js or browser-based projects, use npm or yarn:
npm install @qdrant/js-client-rest
# or
yarn add @qdrant/js-client-rest
This package provides a REST client for Qdrant, suitable for both server-side JavaScript applications and client-side web applications, though careful consideration of API keys and security is needed for client-side use. TypeScript definitions are included, offering type safety for developers using TypeScript.
Java
For Maven-based Java projects, add the following dependency to your pom.xml:
<dependency>
<groupId>io.qdrant</groupId>
<artifactId>client</artifactId>
<version>1.8.0</version> <!-- Use the latest version -->
</dependency>
Replace 1.8.0 with the latest stable Qdrant Java client version. For Gradle projects, the equivalent dependency declaration would be implementation 'io.qdrant:client:1.8.0'.
C#
For .NET projects, use the .NET CLI:
dotnet add package Qdrant.Client
This command adds the Qdrant client NuGet package to your project. Developers can then use the classes and methods provided by the Qdrant.Client namespace to interact with a Qdrant instance. The C# client often follows asynchronous programming patterns, aligning with modern .NET best practices for I/O-bound operations.
Quickstart example
This Python example demonstrates how to connect to a Qdrant instance, create a collection, insert a vector, and perform a simple search. This snippet assumes you have a running Qdrant instance, either locally or via Qdrant Cloud.
from qdrant_client import QdrantClient, models
import numpy as np
# Initialize Qdrant client
# For a local instance: client = QdrantClient(host="localhost", port=6333)
# For Qdrant Cloud: client = QdrantClient(
# host="YOUR_QDRANT_CLOUD_URL",
# api_key="YOUR_API_KEY",
# )
client = QdrantClient(":memory:") # Use in-memory Qdrant for simplicity in this example
collection_name = "my_vectors"
vector_size = 4 # Example vector dimension
# 1. Create a collection
client.recreate_collection(
collection_name=collection_name,
vectors_config=models.VectorParams(
size=vector_size,
distance=models.Distance.COSINE
),
)
print(f"Collection '{collection_name}' recreated.")
# 2. Insert vectors
vectors_to_insert = [
models.PointStruct(
id=1,
vector=[0.1, 0.2, 0.3, 0.4],
payload={"name": "vector_a", "category": "electronics"}
),
models.PointStruct(
id=2,
vector=[0.5, 0.6, 0.7, 0.8],
payload={"name": "vector_b", "category": "clothing"}
),
models.PointStruct(
id=3,
vector=[0.15, 0.25, 0.35, 0.45],
payload={"name": "vector_c", "category": "electronics"}
)
]
client.upsert(
collection_name=collection_name,
wait=True,
points=vectors_to_insert,
)
print(f"Inserted {len(vectors_to_insert)} points.")
# 3. Perform a search
query_vector = [0.1, 0.2, 0.3, 0.4]
search_result = client.search(
collection_name=collection_name,
query_vector=query_vector,
limit=2,
query_filter=models.Filter(
must=[
models.FieldCondition(
key="category",
match=models.MatchValue(value="electronics")
)
]
)
)
print("\nSearch results (top 2 in 'electronics'):")
for hit in search_result:
print(f" ID: {hit.id}, Score: {hit.score:.4f}, Payload: {hit.payload}")
# 4. Retrieve a specific point by ID
retrieved_point = client.retrieve(
collection_name=collection_name,
ids=[1],
with_payload=True,
with_vectors=False
)
print(f"\nRetrieved point 1: {retrieved_point}")
# 5. Delete a point
client.delete(collection_name=collection_name, points_selector=models.PointIdsList(points=[2]))
print("\nPoint with ID 2 deleted.")
# Verify deletion
remaining_points = client.scroll(collection_name=collection_name, limit=10)
print("Remaining points after deletion:")
for point in remaining_points[0]:
print(f" ID: {point.id}, Payload: {point.payload}")
This example initializes an in-memory Qdrant client for demonstration purposes. In a production environment, you would replace QdrantClient(":memory:") with connection details for a local Qdrant server or a Qdrant Cloud instance, including your host URL and API key for secure access. The example demonstrates basic collection creation, upserting data points with vectors and payloads, performing a filtered search, retrieving a specific point, and deleting a point. This sequence covers fundamental operations for interacting with Qdrant and managing vector data, which is crucial for applications such as semantic search systems and personalized recommendations.
Community libraries
Beyond the official SDKs, the Qdrant ecosystem includes various community-contributed libraries and integrations. These typically extend Qdrant's functionality or provide wrappers for specific use cases or frameworks not directly covered by the official clients. Community efforts often emerge to support niche programming languages, integrate with popular machine learning frameworks, or offer specialized utilities.
Examples of community contributions might include:
- Integrations with ORMs or data frameworks: Libraries that allow Qdrant to be used alongside existing database abstraction layers.
- Wrappers for less common languages: Clients developed by the community for languages where an official SDK is not yet available.
- Tools for data migration or synchronization: Utilities to move data between Qdrant and other systems.
- Specialized UI tools: Dashboards or visualization tools built on top of Qdrant's API.
While community libraries can offer flexibility and address specific needs, their maintenance and support levels can vary. Developers considering these options should review the project's activity, documentation, and community support channels. The Qdrant documentation portal and community forums are often good starting points to discover and evaluate such contributions. These community-driven projects highlight the extensibility of Qdrant and the active participation of its user base, further enriching the options available for developers.