Official language bindings#
The pgvector GitHub organisation maintains client libraries for over 30 languages. They do one job: convert between your language's arrays and pgvector's types, so you never hand-format '[1,2,3]' strings — and you avoid the operator does not exist: vector <-> text error.
| Language | Install | Latest version | Works with |
|---|---|---|---|
| Python | pip install pgvector | 0.5.1 (2026-10-09) | Psycopg 3 & 2, asyncpg, pg8000, SQLAlchemy, SQLModel, Django, Peewee |
| Node.js / TypeScript | npm install pgvector | 0.3.0 (2026-05-31) | node-postgres, Postgres.js, Kysely, Knex, Sequelize, TypeORM, MikroORM, Prisma, Drizzle, Bun SQL… |
| Go | go get github.com/pgvector/pgvector-go | v0.4.1 (2026-07-30) | pgx, pg, Bun, Ent, GORM, sqlx |
| Rust | pgvector = { version = "0.4", features = ["postgres"] } | 0.4.2 (2026-05-22) | rust-postgres, SQLx, Diesel |
| Ruby | gem "pgvector" · Rails: gem "neighbor" | 0.3.3 · neighbor 1.2.0 | pg, Sequel, Active Record (via neighbor) |
| Java / Kotlin | Maven com.pgvector:pgvector | 0.1.6 (2024-07-17) | JDBC, Spring JDBC, Hibernate, R2DBC |
| C# / .NET | dotnet add package Pgvector | 0.3.2 · EF Core 0.3.0 | Npgsql (C#, F#, VB), Dapper, Entity Framework Core |
| PHP | composer require pgvector/pgvector | v0.2.2 | Laravel, Symfony, Doctrine, PgSql |
| Elixir | {:pgvector, "~> 0.4.0"} | 0.4.2 (2026-10-02) | Ecto, Postgrex |
| Dart | dart pub add pgvector | 0.2.0 | postgres package |
Also available: C, C++, Swift, Julia, Zig, Haskell, OCaml, Perl, R, Lua, Nim, Crystal, D and more — see the language table in the upstream README. Note that the Java binding's latest release on Maven Central is from July 2024.
Python (psycopg 3)#
import numpy as np
import psycopg
from pgvector.psycopg import register_vector
conn = psycopg.connect("dbname=app", autocommit=True)
conn.execute("CREATE EXTENSION IF NOT EXISTS vector")
register_vector(conn) # after CREATE EXTENSION: it looks up the vector type's OID
conn.execute("CREATE TABLE documents (id bigserial PRIMARY KEY, content text, embedding vector(3))")
conn.execute("INSERT INTO documents (content, embedding) VALUES (%s, %s)", ("hello", np.array([1, 2, 3])))
rows = conn.execute(
"SELECT content, embedding <=> %s AS distance FROM documents ORDER BY distance LIMIT 5",
(np.array([1, 2, 4]),),
).fetchall()
print(rows) # [('hello', 0.00853986601633272)]Python (SQLAlchemy 2)#
from pgvector.sqlalchemy import Vector
from sqlalchemy import BigInteger, Text, create_engine, select
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column
class Base(DeclarativeBase):
pass
class Document(Base):
__tablename__ = "documents"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
content: Mapped[str] = mapped_column(Text)
embedding = mapped_column(Vector(3))
engine = create_engine("postgresql+psycopg://localhost/app")
with Session(engine) as session:
session.add(Document(content="hello", embedding=[1, 2, 3]))
session.commit()
query = [1, 2, 4]
stmt = (select(Document.content, Document.embedding.cosine_distance(query).label("distance"))
.order_by(Document.embedding.cosine_distance(query)).limit(5))
print(session.execute(stmt).all()) # [('hello', 0.00853986601633272)]Comparators: l2_distance, cosine_distance, max_inner_product, l1_distance, hamming_distance, jaccard_distance. Types: VECTOR, HALFVEC, BIT, SPARSEVEC.
Node.js (node-postgres)#
import pg from 'pg';
import pgvector from 'pgvector/pg';
const client = new pg.Client();
await client.connect();
await client.query('CREATE EXTENSION IF NOT EXISTS vector');
await pgvector.registerTypes(client);
await client.query('INSERT INTO documents (content, embedding) VALUES ($1, $2)',
['hello', pgvector.toSql([1, 2, 3])]);
const res = await client.query(
'SELECT content, embedding, embedding <=> $1 AS distance FROM documents ORDER BY distance LIMIT 5',
[pgvector.toSql([1, 2, 4])]);
console.log(res.rows);
// [ { content: 'hello', embedding: [ 1, 2, 3 ], distance: 0.00853986601633272 } ]Frameworks and ORMs#
| Framework | Package | pgvector support |
|---|---|---|
| LangChain (Python) | langchain-postgres 0.0.19 | Use PGVectorStore + PGEngine (sync and async, hybrid search with RRF). The older PGVector class is deprecated since 0.0.14. |
| LlamaIndex | llama-index-vector-stores-postgres 0.9.0 | PGVectorStore.from_params(…); query modes default, hybrid, sparse, text search, MMR. |
| Django | pgvector (Python) | VectorField, HalfVectorField, BitField, SparseVectorField; CosineDistance etc.; HnswIndex, IvfflatIndex; VectorExtension() migration. |
| Rails | neighbor 1.2.0 | has_neighbors :embedding, nearest_neighbors(:embedding, distance: "cosine"); halfvec, bit and sparsevec. |
| Drizzle ORM | drizzle-orm 0.45.4 | Built-in vector/halfvec/bit/sparsevec columns, cosineDistance() etc., HNSW index helper. You still run CREATE EXTENSION yourself. |
| Prisma | prisma 7.10.1 | Unsupported("vector(1536)") columns plus raw SQL; prisma migrate dev doesn't manage vector indexes. Prisma 8 (release candidate) adds a dedicated pgvector package. |
| Spring AI, Semantic Kernel, Haystack | — | Each ships a pgvector vector store; check its docs for the version you use. |
LangChain migration. Tutorials still import langchain_community.vectorstores.PGVector or langchain_postgres.PGVector. Both are superseded by langchain_postgres.PGVectorStore, which uses its own table layout — follow the package's migration notebook to move existing collections.
Extensions built around pgvector#
Several projects add index types pgvector doesn't have. All are separate installs; most reuse pgvector's vector type.
| Extension | From | What it adds | Status (2026-10-27) | License |
|---|---|---|---|---|
| pg_vectorsearch | Tiger Data | PRISM index (IVF-style centroid tree + RaBitQ quantization + full-precision rerank) over pgvector vector/halfvec columns. Postgres 18+. | v0.1.0, alpha (announced 2026-10-13) | PostgreSQL |
| pgvectorscale | Tiger Data | StreamingDiskANN index, Statistical Binary Quantization, label-filtered search. | 0.9.1; moving to maintenance mode in favour of pg_vectorsearch | PostgreSQL |
VectorChord (vchord) | TensorChord | vchordrq index using RaBitQ with reranking; pgvector-compatible types and syntax. | 1.1.1 (Feb 2026) | AGPLv3 or ELv2 |
| pgvecto.rs | TensorChord | Rust vector extension. | Superseded by VectorChord (README asks users to migrate) | Apache-2.0 |
| Lantern | Lantern | HNSW via usearch. | No commits since Dec 2024 — appears inactive | AGPLv3 |
| pg_diskann | Azure | DiskANN index, Azure Database for PostgreSQL only. | 0.6.5 on PG 14–18 | Managed |
| alloydb_scann | Google AlloyDB | ScaNN index on AlloyDB. | 0.1.3 | Managed |
RaBitQ, which pg_vectorsearch and VectorChord both use, quantises each dimension to one bit with a provable bound on the distance error (Gao & Long, SIGMOD 2024, arXiv:2405.12497). pgvector's own answer to the same problem is binary_quantize() plus re-ranking, which we benchmarked.
Hosted Postgres with pgvector#
Documented pgvector versions as of 2026-10-27 (most providers lag the 0.8.7 release — see what that means):
| Provider | Documented version | Notes |
|---|---|---|
| Amazon RDS for PostgreSQL | 0.8.2 (PG 14–18) | 0.8.0 on PG 13. |
| Amazon Aurora PostgreSQL | 0.8.2 | Latest minors of 14–18; previous minors have 0.8.1. |
| Google Cloud SQL | 0.8.5 (PG 13+) | |
| Google AlloyDB | 0.8.5.google-1 | Also offers the ScaNN index. |
| Azure Database for PostgreSQL | 0.8.2 (PG 13–18) | Allow-list in azure.extensions first; also offers pg_diskann. |
| Neon | 0.8.6 (PG 18), 0.8.0 (PG 14–17) | Compute restart needed to pick up new versions. |
| Supabase | Not stated | Enable in Dashboard → Extensions; installed in the extensions schema. |
| Tiger Cloud | Not stated | pgvector, pgvectorscale and pg_textsearch available, not enabled by default. |
| DigitalOcean | Not stated | Pre-installed on Advanced Edition (PG 16–18). |
| Crunchy Bridge · Heroku · Render | Not stated | CREATE EXTENSION vector; |
Whatever the docs say, your instance is the ground truth: SELECT default_version, installed_version FROM pg_available_extensions WHERE name = 'vector';
Operational tooling#
pg_stat_statements— find your slowest vector queries; it ships with Postgres.pg_stat_progress_create_index— watch HNSW and IVFFlat builds (query).- Citus — distributes tables (and their HNSW indexes) across nodes when one machine isn't enough.
- Our tools — the index planner and storage calculator size an index before you build it.