Vector Search & RAG

Build AI applications with semantic search. Telbase's PostgreSQL databases support the pgvector extension: your agent turns it on for the app's database with one command.

How It Works

  1. The agent registers the app with a PostgreSQL database: telbase apps create my-app --provider cloudrun --database postgres.
  2. It turns on pgvector, with the embedding preset that matches the app's embedding model:
bash
telbase db enable-extension pgvector --project my-app --preset openai-3-small
  1. It creates the app's tables with the app's own tooling, through telbase db run.
PostgreSQL only
pgvector works with PostgreSQL databases. SQLite databases don't support vector extensions. telbase db extensions --project my-app lists the extensions available: pgvector, PostGIS, pg_trgm and uuid-ossp.

Embedding Presets

Pass one with --preset; it sets the dimensions and the index. Without one, pgvector is enabled with 1,536 dimensions and an HNSW index (--dimensions, --index-type and --metric change them).

PresetDimensionsIndex TypeUse Case
openai-ada-0021,536HNSWLegacy OpenAI embeddings
openai-3-small1,536HNSWOpenAI text-embedding-3-small (default)
openai-3-large3,072NoneOpenAI text-embedding-3-large
claude1,024HNSWAnthropic / Voyage AI embeddings
cohere-english1,024HNSWCohere embed-english-v3
sentence-transformers384HNSWall-MiniLM-L6-v2 and similar
HNSW dimension limit
PostgreSQL's vector type has a hard 2,000-dimension limit for HNSW and IVFFlat indexes. The openai-3-large preset (3,072 dimensions) automatically disables indexing. For most RAG apps, openai-3-small (1,536 dimensions) offers the best balance of quality and performance.

A sample table

--create-table also creates an embeddings table (--table-name and --column-name name it):

bash
telbase db enable-extension pgvector --project my-app --preset claude --create-table

Manual Setup

Or create the extension and your own embeddings table in SQL.

sql
-- Enable the pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Create an embeddings table (1536 dimensions for OpenAI)
CREATE TABLE documents (
  id SERIAL PRIMARY KEY,
  content TEXT NOT NULL,
  embedding vector(1536)
);

-- Create an HNSW index for fast similarity search
CREATE INDEX ON documents
  USING hnsw (embedding vector_cosine_ops);

You can run this SQL directly: telbase db exec --project my-app --file setup.sql

Using with Claude Code

Ask Claude in plain words; with the skills it runs the commands above.

bash
"Deploy my RAG app to Telbase with a PostgreSQL database and pgvector"

"Enable pgvector on my app's database with the openai-3-small preset"

With the MCP server registered, the enable_database_extension tool does the same.

Next Steps