Open-source note · 02

pgvector: a durable retrieval layer

pgvector adds vector similarity search to Postgres. Pair it with AIWave’s live qwen3.7-text-embedding catalog entry for a small, inspectable retrieval workflow.

IntermediateVerified 2026-09-25

Why this project

pgvector was on the weekly GitHub Trending page fetched on 2026-09-25. Its official README documents exact and approximate nearest-neighbor search, cosine distance, and Postgres storage. We selected it because it gives an agent a concrete place to store and inspect retrieved context.

Sources: official repository and weekly Trending list, checked 2026-09-25.

Run the smallest path

CREATE EXTENSION vector;
CREATE TABLE notes (id bigserial PRIMARY KEY, body text NOT NULL, embedding vector(4));
INSERT INTO notes (body, embedding) VALUES
  ('Password reset needs an email link', '[0.1,0.2,0.3,0.4]'),
  ('Billing webhook retries should be idempotent', '[0.4,0.3,0.2,0.1]');
SELECT body FROM notes ORDER BY embedding <-> '[0.1,0.2,0.3,0.4]' LIMIT 1;

For production dimensions, use the embedding model’s documented output size; the four-dimensional example is only a local SQL smoke test.

from openai import OpenAI
import os
client = OpenAI(base_url="https://aiwave.live/v1", api_key=os.environ["AIWAVE_API_KEY"])
r = client.embeddings.create(model="qwen3.7-text-embedding", input="Password reset needs an email link")
print(len(r.data[0].embedding))

Cost estimate

AssumptionEstimate
10,000 input tokens for embeddingabout $0.0011 at the listed input rate
Rate sourceAIWave pricing, qwen3.7-text-embedding, effective 2026-08-27; checked 2026-09-25

Guardrails