Prompt
vector database with python sdk
Latest observation
Oct 7, 2026
OpenAI APIWeb search: off
If you want to use a vector database with a Python SDK, here are the most common options and how to get started quickly.
Popular vector databases with Python SDKs
- Pinecone — fully managed, easy to use
- Weaviate — open-source and managed options
- Qdrant — open-source and managed
- Milvus — open-source, scalable
- Chroma — simple local/vector store for prototyping
- FAISS — library for vector search, not a database
Example: Qdrant with Python SDK
Install
pip install qdrant-client
Basic usage
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct
client = QdrantClient(host="localhost", port=6333)
# Create collection
client.create_collection(
collection_name="my_collection",
vectors_config=VectorParams(size=4, distance=Distance.COSINE),
)
# Insert vectors
client.upsert(
collection_name="my_collection",
points=[
PointStruct(id=1, vector=[0.1, 0.2, 0.3, 0.4], payload={"text": "hello"}),
PointStruct(id=2, vector=[0.2, 0.1, 0.4, 0.3], payload={"text": "world"}),
],
)
# Search
results = client.search(
collection_name="my_collection",
query_vector=[0.1, 0.2, 0.3, 0.4],
limit=2,
)
for r in results:
print(r.id, r.score, r.payload)
Example: Pinecone with Python SDK
Install
pip install pinecone
Basic usage
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("my-index")
index.upsert([
("id1", [0.1, 0.2, 0.3], {"text": "hello"}),
("id2", [0.3, 0.2, 0.1], {"text": "world"}),
])
res = index.query(vector=[0.1, 0.2, 0.3], top_k=2, include_metadata=True)
print(res)
Example: Chroma
Install
pip install chromadb
Basic usage
import chromadb
client = chromadb.Client()
collection = client.create_collection("my_collection")
collection.add(
ids=["1", "2"],
embeddings=[[0.1, 0.2, 0.3], [0.3, 0.2, 0.1]],
metadatas=[{"text": "hello"}, {"text": "world"}],
)
results = collection.query(
query_embeddings=[[0.1, 0.2, 0.3]],
n_results=2
)
print(results)
Which should you choose?
- Quick prototype / local app: Chroma
- Production with managed service: Pinecone
- Open-source production option: Qdrant or Weaviate
- Large-scale self-hosted: Milvus
- Pure similarity search library: FAISS
If you want, I can also give you:
- a full Python example with embeddings + vector DB
- a comparison table of Pinecone vs Qdrant vs Weaviate vs Chroma
- a Docker setup for local vector DB testing