Skip to main content
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
{
  "mcpServers": {
    "respan-docs": {
      "url": "https://docs.respan.ai/mcp"
    }
  }
}

What is Qdrant?

Qdrant is an open-source vector similarity search engine with advanced filtering and payload support. Respan auto-instruments Qdrant operations so every upsert, search, and collection operation is captured as a traced span.

Setup

1

Install packages

pip install respan-ai opentelemetry-instrumentation-qdrant qdrant-client python-dotenv
2

Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
export QDRANT_URL="YOUR_QDRANT_URL"
export QDRANT_API_KEY="YOUR_QDRANT_API_KEY"
3

Initialize and run

import os
from dotenv import load_dotenv

load_dotenv()

from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct
from respan import Respan

# Initialize Respan with auto-instrumentation
respan = Respan(is_auto_instrument=True)

# Create a Qdrant client
client = QdrantClient(
    url=os.getenv("QDRANT_URL"),
    api_key=os.getenv("QDRANT_API_KEY"),
)

# Create a collection
client.create_collection(
    collection_name="respan-demo",
    vectors_config=VectorParams(size=1536, distance=Distance.COSINE),
)

# Upsert points
client.upsert(
    collection_name="respan-demo",
    points=[
        PointStruct(id=1, vector=[0.1] * 1536, payload={"genre": "drama"}),
        PointStruct(id=2, vector=[0.2] * 1536, payload={"genre": "comedy"}),
    ],
)

# Search
results = client.search(
    collection_name="respan-demo",
    query_vector=[0.1] * 1536,
    limit=3,
)
print(results)

respan.flush()
4

View your trace

Open the Traces page to see your Qdrant spans including collection creation, upsert, and search operations.

Configuration

ParameterTypeDefaultDescription
api_keystr | NoneNoneFalls back to RESPAN_API_KEY env var.
base_urlstr | NoneNoneFalls back to RESPAN_BASE_URL env var.
is_auto_instrumentbool | NoneFalseAuto-discover installed instrumentors. Required for Traceloop instrumentors.
customer_identifierstr | NoneNoneDefault customer identifier for all spans.
metadatadict | NoneNoneDefault metadata attached to all spans.
environmentstr | NoneNoneEnvironment tag (e.g. "production").

Attributes

Attach customer identifiers, thread IDs, and metadata to spans.

In Respan()

Set defaults at initialization — these apply to all spans.
from respan import Respan

respan = Respan(
    is_auto_instrument=True,
    customer_identifier="user_123",
    metadata={"service": "search-api", "version": "1.0.0"},
)

With propagate_attributes

Override per-request using a context manager.
from respan import Respan, propagate_attributes

respan = Respan(is_auto_instrument=True)

with propagate_attributes(
    customer_identifier="user_456",
    thread_identifier="session_abc",
    metadata={"plan": "enterprise"},
):
    results = client.search(
        collection_name="respan-demo",
        query_vector=[0.1] * 1536,
        limit=5,
    )
    print(results)
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related messages into a conversation.
metadatadictCustom key-value pairs. Merged with default metadata.

Examples

Create collection

from qdrant_client.models import Distance, VectorParams

client.create_collection(
    collection_name="product-embeddings",
    vectors_config=VectorParams(size=1536, distance=Distance.COSINE),
)

Upsert points

from qdrant_client.models import PointStruct

client.upsert(
    collection_name="product-embeddings",
    points=[
        PointStruct(
            id=1,
            vector=[0.12, 0.34, 0.56] + [0.0] * 1533,
            payload={"category": "electronics", "price": 299.99},
        ),
        PointStruct(
            id=2,
            vector=[0.78, 0.91, 0.23] + [0.0] * 1533,
            payload={"category": "clothing", "price": 49.99},
        ),
    ],
)
from qdrant_client.models import Filter, FieldCondition, MatchValue

results = client.search(
    collection_name="product-embeddings",
    query_vector=[0.12, 0.34, 0.56] + [0.0] * 1533,
    limit=5,
    query_filter=Filter(
        must=[FieldCondition(key="category", match=MatchValue(value="electronics"))]
    ),
)

for point in results:
    print(f"id={point.id}, score={point.score:.4f}, payload={point.payload}")

Delete

from qdrant_client.models import PointIdsList, Filter, FieldCondition, MatchValue

# Delete by IDs
client.delete(
    collection_name="product-embeddings",
    points_selector=PointIdsList(points=[1, 2]),
)

# Delete by filter
client.delete(
    collection_name="product-embeddings",
    points_selector=Filter(
        must=[FieldCondition(key="category", match=MatchValue(value="electronics"))]
    ),
)