# pgvector — card for AI agents

Postgres extension adding vector columns and exact/approximate nearest-neighbor search (HNSW, IVFFlat).

Maker: pgvector (open source project) · category: Vector databases

## Price (official page)
- Free tier: none listed
- Free tier terms: open source (read from the wording above and the pricing page; empty = not stated)
- Note: Free extension; available on most managed Postgres services (pricing is the host's).

## Connect
- npm: `npm install pgvector`
- PyPI: `pip install pgvector`
- Repository: https://github.com/pgvector/pgvector

## For AI agents on pgvector (open source project)'s own site (AgentGid check 2026-11-13: 3 of 6)
- llms.txt: https://github.com/llms.txt (full text: https://github.com/llms-full.txt)
- Docs pages as Markdown: 0% of the pages llms.txt lists
- OpenAPI description: none found at the usual places
- Official MCP server: no · official SDK: yes · status page: no
- robots.txt lets AI assistants (ChatGPT-User, Claude-User) read the site: yes

## Price history in AgentGid's catalog (since 2026-10-10)
- Changes recorded: 0 (a vendor price change or an editor's correction; the evidence archive keeps the pricing page of each date)

## Other APIs in this category
- Algolia: https://agentgid.com/apis/algolia/agent.md
- Supabase (pgvector): https://agentgid.com/apis/supabase-pgvector/agent.md
- Elasticsearch (Elastic Cloud): https://agentgid.com/apis/elastic-cloud/agent.md
- Qdrant Cloud: https://agentgid.com/apis/qdrant-cloud/agent.md
- turbopuffer: https://agentgid.com/apis/turbopuffer/agent.md

## Links
- AgentGid page: https://agentgid.com/apis/pgvector/


## pgvector: search by meaning inside your Postgres database

pgvector is a free add-on for the Postgres database, not an online service with its own key. It lets your database store embeddings, lists of numbers that describe the meaning of a text or picture, next to your normal rows. Then one query finds the rows closest in meaning, such as similar products or matching help articles.

### Where to use it
- Answers from your own documents: Store your help articles or notes with their embeddings, find the passages closest to a question, and give them to an AI model to answer from.
- Similar products on a shop page: Show "you may also like" items whose descriptions or photos are closest to the one a shopper is looking at.
- Search inside one customer's data: In an app with many customers, each search looks only at that customer's rows, and the closest matches still come back first.
- Keyword and meaning search together: Combine normal word search with search by meaning, so exact product codes and loosely worded questions both find the right page.
- Find pictures that look alike: Store an embedding for every uploaded image and find the ones that look closest to a new picture.
- Spot duplicate support tickets: When a new ticket comes in, look up earlier tickets with the closest meaning and link them, so the team answers once. (idea, not from the official pages)

### How to start
- Install the extension on your Postgres server (or pick a hosted Postgres that already has it).

```
cd /tmp
git clone --branch v0.8.7 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudo
```

- Turn it on once in each database that should use it.

```
CREATE EXTENSION vector;
```

- Add a vector column and search for the nearest rows.

```
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
```


### License
Free and open source under the PostgreSQL License. You may use, change and pass it on for any purpose, also in paid products, as long as the copyright notice stays in copies.

### Good to know
- It is not a hosted service. You need a Postgres database where pgvector is installed, your own or from a hosting provider.
- pgvector does not make embeddings. You create them with a separate model or service and store the numbers.
- Without an index every search compares all rows, which is exact but slower on large tables. An index is faster but may miss a few matches.
- Search results can change after you add a fast index, unlike with normal database indexes.

Checked 2026-11-10 against: https://github.com/pgvector/pgvector, https://github.com/pgvector/pgvector/blob/master/README.md, https://github.com/pgvector/pgvector/blob/master/LICENSE, https://github.com/pgvector/pgvector/issues/54, https://github.com/pgvector/pgvector-python/blob/master/README.md, https://github.com/pgvector/pgvector-python/blob/master/examples/openai/example.py, https://github.com/pgvector/pgvector-node/blob/master/README.md, https://pypi.org/pypi/pgvector/0.5.1/json, https://registry.npmjs.org/pgvector/0.3.1, https://www.postgresql.org/docs/current/libpq-envars.html, https://registry.npmjs.org/@electric-sql/pglite/0.5.16, https://registry.npmjs.org/@electric-sql/pglite-pgvector/0.0.17

### Mistakes to avoid
- Don't: Sorting by 1 - cosine distance DESC to get the most similar rows. → Do: ORDER BY the cosine distance operator itself, ascending, with LIMIT, and compute similarity in the SELECT list. (An expression in ORDER BY stops Postgres from using the vector index.)
- Don't: Creating an IVFFlat index on an empty table right after CREATE TABLE. → Do: Load data first, then create the IVFFlat index (or use HNSW, which needs no data to build). (An IVFFlat index built with too little data returns fewer results.)
- Don't: An HNSW index on vector(3072) for a large embedding model. → Do: Store halfvec(3072) or index an expression cast to halfvec, which indexes up to 4,000 dimensions. (Indexes on the vector type stop at 2,000 dimensions.)
- Don't: Building the index with one distance and querying with another. → Do: Match the ops class to the operator, for example vector_cosine_ops for cosine distance queries. (Each distance function needs its own index.)
- Don't: Passing Python lists to psycopg without registering the vector type. → Do: Call register_vector(conn) after connecting (or in the pool's configure callback). (The Python helper needs the types registered on each connection.)

### Questions
- Do I need an account or a key for pgvector? No. It is a free extension that runs inside your own Postgres; you only need the database login.
- Which programming languages can use it? Any language with a Postgres client; the project keeps helper libraries for Python, JavaScript, Go, Ruby and many more.
- My embeddings have 3,072 numbers. Can I index them? The vector type indexes up to 2,000 dimensions; use half-precision vectors (up to 4,000) or binary quantization for more.
- Does it work with backups and replicas? Yes. It uses the Postgres write-ahead log, so replication and point-in-time recovery work.
- How do I update it later? Install the new version the same way, then run ALTER EXTENSION vector UPDATE in each database.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
