
pgvector Framework Integrations & SDKs 2026
pgvector integrates natively with LangChain and LlamaIndex, plus Django, SQLAlchemy and 13 Node.js drivers. Teams on Postgres skip a separate vector service.
pgvector Framework Integrations verdict
pgvector integrates natively with LangChain, through langchain-postgres v0.0.17, and LlamaIndex.
Through llama-index-vector-stores-postgres v0.8.1, for Python RAG pipelines. Django, SQLAlchemy and psycopg3 or asyncpg cover direct access.
If your stack is Python on LangChain or LlamaIndex, pgvector setup takes a pip install and a connection string. For Node.js, the pgvector npm package covers all major ORMs. Teams already running Postgres avoid adding a separate vector database service entirely.
- langchain-postgres replaces the deprecated langchain-community PGVector class, so existing code using langchain-community.vectorstores.PGVector must migrate to langchain-postgres.PGVector.
- langchain-postgres requires psycopg3, not psycopg2, and the connection string prefix is postgresql+psycopg, not postgresql+psycopg2.
- llama-index-vector-stores-postgres requires Python 3.10 or newer, while the base pgvector Python package only requires 3.9 or newer.
- There is no official Go, Rust, Java or PHP pgvector client, so those ecosystems access vectors through the standard Postgres wire protocol and SQL operators.
- LangChain package
- langchain-postgres v0.0.17
- LlamaIndex package
- llama-index-vector-stores-postgres v0.8.1
- Node.js drivers supported
- 13
- Python ORMs supported
- Django, SQLAlchemy, Peewee, SQLModel
- Official Go / Rust client
- No
pgvector framework and orchestration integrations
| Integration | Type | Capabilities | Setup |
|---|---|---|---|
| LangChain | Native | RAG orchestration · Hybrid search · Metadata filtering | Low |
| LlamaIndex | Native | Vector index · Hybrid search · MMR retrieval · Metadata filtering | Low |
| Django (ORM) | Native | Vector field · ORM query · Nearest neighbor | Low |
| SQLAlchemy | Native | Vector type · ORM · Distance methods | Low |
| psycopg 3 / psycopg 2 | Driver | Raw SQL · Vector serialization · Async support | Low |
| asyncpg | Driver | Async queries · High-throughput inserts | Low |
| node-postgres (pg) | Driver | Node.js queries · Vector insert/query | Low |
| Prisma / TypeORM / Drizzle | ORM | TypeScript ORM · Vector column · Nearest neighbor | Medium |
Find your integration path into pgvector
- LangChain is a native integration (RAG orchestration, Hybrid search, Metadata filtering), low setup effort.
- No official SDK from pgvector. Use a community client or the REST API directly.
- Install:
pip install langchain-postgres
Based on pgvector's documented integrations and official SDK matrix.
LangChain + pgvector quickstart
from langchain_postgres import PGVector
from langchain_openai import OpenAIEmbeddings
# Connect to an existing Postgres database with pgvector installed
connection = "postgresql+psycopg://user:pass@localhost:5432/mydb"
vector_store = PGVector(
embeddings=OpenAIEmbeddings(model="text-embedding-3-large"),
collection_name="my_docs",
connection=connection,
use_jsonb=True,
)
# Index documents
vector_store.add_documents(docs)
# Retrieve with metadata filter
hits = vector_store.similarity_search("how does billing work?", k=4, filter={"source": "docs"})
# Or get results with similarity scores
scored = vector_store.similarity_search_with_score("query text", k=5)Python client packages and versions
| Package | Version | Released | Status |
|---|---|---|---|
| pgvector (PyPI) | 0.4.2 | Dec 5, 2025 | Official |
| langchain-postgres | 0.0.17 | Feb 17, 2026 | Official |
| llama-index-vector-stores-postgres | 0.8.1 | Mar 13, 2026 | Official |
| Python requirement | >=3.9 (>=3.10 for LI) | — | Requirement |
pgvector LangChain integration detail
- Installed via pip install langchain-postgres; requires psycopg3 (not psycopg2)
- Primary class is PGVector (imported from langchain_postgres); connect via a psycopg3 connection string
- Supports add_documents(), delete(), similarity_search(), similarity_search_with_score(), and as_retriever()
- Metadata filter operators: $eq, $ne, $lt, $lte, $gt, $gte, $in, $nin, $between, $like, $ilike, $and, $or
- Connection string format: postgresql+psycopg://user:pass@host/db (psycopg3 driver, not psycopg2)
- Supports hybrid search combining vector similarity and keyword-based search via reciprocal rank fusion
pgvector LlamaIndex integration detail
- Installed via pip install llama-index-vector-stores-postgres (v0.8.1, Mar 2026); requires Python >=3.10
- Primary class is PGVectorStore, initialized via PGVectorStore.from_params() with host/port/db/embed_dim
- Supports multiple query modes: vector similarity, hybrid (dense + sparse), BM25 text search, and MMR for diverse results
- HNSW parameters (m, ef_construction, ef_search, dist_method) are configurable at PGVectorStore creation via hnsw_kwargs
- Metadata filter operators include >=, <=, in, nin, contains, and nested AND/OR logic
- Custom SQL query building is supported via customize_query_fn for table joins and advanced retrieval
pgvector Framework Integrations FAQ
How do I use pgvector with LangChain?
Install langchain-postgres and psycopg with the binary extra, then import PGVector from langchain_postgres. Connect using a psycopg3 connection string, with the postgresql+psycopg prefix, set collection_name and embeddings, then call add_documents to index and similarity_search to retrieve. Note that langchain-postgres uses psycopg3, not psycopg2, and the old langchain-community PGVector class is deprecated.
How do I use pgvector with LlamaIndex?
Install llama-index-vector-stores-postgres, at v0.8.1, which requires Python 3.10 or newer, and initialize PGVectorStore through PGVectorStore.from_params, passing host, port, database, table_name and embed_dim. Supported query modes include vector similarity, hybrid dense-plus-sparse, BM25, full-text and MMR for diverse results.
Which Python drivers does pgvector support?
The pgvector Python package v0.4.2 supports psycopg3, psycopg2, asyncpg, pg8000, Django, SQLAlchemy, SQLModel and Peewee. langchain-postgres requires psycopg3 specifically. asyncpg is available for high-throughput async workloads.
Which Node.js drivers does pgvector support?
The pgvector npm package v0.3.0 supports 13 drivers: node-postgres, Prisma, TypeORM, Drizzle ORM, Knex.js, Objection.js, Kysely, Sequelize, pg-promise, Postgres.js, Slonik, MikroORM and Bun SQL. It also supports Deno and WebAssembly environments.
Is there a pgvector client for Go or Rust?
No dedicated pgvector client exists for Go or Rust. Teams using those languages access pgvector through the standard Postgres wire protocol and the SQL distance operators, directly through existing Postgres drivers such as pgx for Go or tokio-postgres for Rust.
Sources & verification
| Source | What was checked | Last checked |
|---|---|---|
| GitHub Pgvector Pgvector | Official product page | July 10, 2026 |
| GitHub Pgvector Pgvector Node | Pgvector Pgvector Node | July 10, 2026 |
| GitHub Pgvector Pgvector Python | Pgvector Pgvector Python | July 10, 2026 |
| Langchain Developer docs | Independent reference | July 10, 2026 |
| Llamaindex Vector Stores Postgres | Independent reference | July 10, 2026 |
| Pypi Project Langchain Postgres | Project Langchain Postgres | July 10, 2026 |
| Pypi Project Llama Index Vector Stores Postgres | Project Llama Index Vector Stores Postgres | July 10, 2026 |
Every fact on this pgvector page is tied to a named source and a verification date. Freshness-sensitive figures trace to the sources above; verify against the vendor before relying on them.
Explore pgvector
Every page on pgvector in one place, you are on framework integrations.
Snapshot, score and verdict
You are here
Latency, throughput, uptime and behaviour under scale
Every tier and the entry price
Compared and ranked vs peers
Price and feature change history
Browse the full Vector Databases category
