pgvector framework integrations
★★★★ 3.9 CE

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

Verified today·7 sources checked

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.

How it fits your stack

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.

Honest limits
  • 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
View sources

pgvector framework and orchestration integrations

IntegrationTypeCapabilitiesSetup
LangChainNativeRAG orchestration · Hybrid search · Metadata filteringLow
LlamaIndexNativeVector index · Hybrid search · MMR retrieval · Metadata filteringLow
Django (ORM)NativeVector field · ORM query · Nearest neighborLow
SQLAlchemyNativeVector type · ORM · Distance methodsLow
psycopg 3 / psycopg 2DriverRaw SQL · Vector serialization · Async supportLow
asyncpgDriverAsync queries · High-throughput insertsLow
node-postgres (pg)DriverNode.js queries · Vector insert/queryLow
Prisma / TypeORM / DrizzleORMTypeScript ORM · Vector column · Nearest neighborMedium

Find your integration path into pgvector

LangChain + pgvector quickstart

pip install langchain-postgres langchain-openai psycopg[binary]python
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

PackageVersionReleasedStatus
pgvector (PyPI)0.4.2Dec 5, 2025Official
langchain-postgres0.0.17Feb 17, 2026Official
llama-index-vector-stores-postgres0.8.1Mar 13, 2026Official
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

Verified by ComparEdgeMethod: Vendor docs, official pages, and selected independent sources
SourceWhat was checkedLast checked
GitHub Pgvector PgvectorOfficial product pageJuly 10, 2026
GitHub Pgvector Pgvector NodePgvector Pgvector NodeJuly 10, 2026
GitHub Pgvector Pgvector PythonPgvector Pgvector PythonJuly 10, 2026
Langchain Developer docsIndependent referenceJuly 10, 2026
Llamaindex Vector Stores PostgresIndependent referenceJuly 10, 2026
Pypi Project Langchain PostgresProject Langchain PostgresJuly 10, 2026
Pypi Project Llama Index Vector Stores PostgresProject Llama Index Vector Stores PostgresJuly 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.