Skip to content

pgembed

Generate vector embeddings through Ollama, OpenAI, or custom HTTP services

pgembed · Generate vector embeddings through Ollama, OpenAI, or custom HTTP services

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101968pgembedpgembed0.1.0RAGTecnisys-Community-1.0Python

PostgreSQL · 13, 14, 15, 16, 17, 18

Relationships
Requiresvector plpython3u

Usage

Sources:

pgembed generates pgvector embeddings through Ollama, OpenAI, or a custom HTTP endpoint. It is implemented with untrusted PL/Python; inference runs in an external service, not inside the database.

Core Workflow

A superuser must make plpython3u and vector available. Start a compatible Ollama server with the requested model before running the query.

CREATE EXTENSION plpython3u;
CREATE EXTENSION vector;
CREATE EXTENSION pgembed;
SELECT pgembed.embed_ollama('PostgreSQL extensions', 'embeddinggemma');
SELECT * FROM pgembed.embed_batch_ollama(
  ARRAY['PostgreSQL extensions', 'Vector similarity'], 'embeddinggemma');

API and Configuration

The embed_ollama, embed_openai, and embed_custom functions in the pgembed schema return vectors; their batch forms handle text arrays. Match the destination vector dimension to the selected model. pgembed.url_allowlist controls accepted hosts. pgembed.max_retries, pgembed.initial_backoff_ms, and pgembed.max_backoff_ms govern retries; pgembed.circuit_breaker_threshold and pgembed.circuit_breaker_reset_timeout_s govern a backend-local circuit breaker.

The README specifies PostgreSQL 13 or newer. No preload or server restart is needed for the extension itself. HTTP calls hold a database backend until completion; remote text and credentials require deliberate access control. A configurable hostname allowlist is not a substitute for database privileges and network policy. Do not put actual API keys in logged SQL. The Tecnisys Community License 1.0 restricts competing hosted-service use.

Table reader