Skip to main content

Prerequisites

  • Docker and Docker Compose
  • An OpenAI API key (or compatible LLM provider)

Quick start

This starts three services:
  • PostgreSQL 16 on port 5432
  • Redis 7 on port 6379
  • Mengram API on port 8420

Verify it’s running

Both /health and /v1/health work.

Create your first account

By default, Mengram requires email verification via Resend. For self-hosting without an email provider, set DISABLE_EMAIL_VERIFICATION=true:
With this enabled, the signup endpoint returns your API key immediately — no verification code needed.
If you prefer to keep email verification, set RESEND_API_KEY and EMAIL_FROM (see Configuration below). Without Resend, verification codes are logged to stdout — check docker compose logs mengram to find them.

Configuration

Environment variables in docker-compose.yml:

Required

Core

Self-hosting

GitHub OAuth (optional)

GitHub login is optional — email signup works without it. To enable GitHub login:
  1. Create a GitHub OAuth App at github.com/settings/developers
  2. Set the callback URL to http://your-host:8420/auth/github/callback
  3. Add both env vars to your docker-compose.yml

Multilingual support (Cohere)

Mengram cloud uses Cohere embed-multilingual-v3.0 for native quality across 23 languages — Russian, Chinese, Spanish, Japanese, Korean, Arabic, and more. To use the same on a self-hosted instance:
Get a Cohere API key at dashboard.cohere.com. The trial tier is free and rate-limited — sufficient for development and small workloads.
Stick with the default EMBEDDING_PROVIDER=openai (uses text-embedding-3-large, 1536 dim) if your data is mostly English. Switch to Cohere if you have non-English users or need cross-lingual retrieval (e.g. English queries finding Russian documents).
Embeddings are written to a separate embedding_v2 column (1024 dim) so you can switch providers without losing existing data — Mengram routes search to the right column based on query vector size.

Use with Ollama (fully local)

Run Mengram with a local LLM — no external API calls:
Make sure Ollama is running on your host machine with the model pulled:

Use with LM Studio

Use with OpenRouter

Connect your tools

MCP server (Claude Desktop, Cursor, Windsurf)

VS Code extension

  1. Install the Mengram extension from the marketplace
  2. Open Settings and set:
    • mengram.apiKey → your API key
    • mengram.baseUrlhttp://localhost:8420

Claude Code hooks

Python SDK

JavaScript SDK

Data persistence

PostgreSQL data is stored in a Docker volume (pgdata). Your memories persist across container restarts. To backup:
To restore:

Production deployment

For production, consider:
  • Use a managed PostgreSQL (e.g., Supabase, Neon, RDS)
  • Use a managed Redis (e.g., Upstash, ElastiCache)
  • Set strong database passwords
  • Put behind a reverse proxy with TLS (nginx, Caddy)
  • Set GUNICORN_WORKERS for concurrency
  • Set BASE_URL to your public domain
The easiest way to deploy is Railway — just connect your GitHub repo and set environment variables. Mengram’s cloud version runs on Railway.