This guide covers the optional features and their configuration in Morphic.
Morphic uses PostgreSQL for chat history storage. A database is optional for basic usage — without it, Morphic runs in a stateless mode where chat history is not persisted.
Set the connection string in .env.local:
DATABASE_URL=postgresql://user:password@localhost:5432/morphicAny PostgreSQL provider works: Neon, Supabase, or a local PostgreSQL instance.
Docker: Database is automatically configured — no need to set this.
After configuring your database, run migrations to create the necessary tables:
bun run migrateThis command applies all migrations from the drizzle/ directory. Docker runs migrations automatically on startup.
Morphic dynamically detects available AI providers based on your API keys and displays a model selector in the UI. Set at least one provider API key to get started.
In Local/Docker mode, the selected model is persisted in a cookie and used for all chat interactions including related question generation.
In Cloud mode (MORPHIC_CLOUD_DEPLOYMENT=true), models are fixed by config/models/cloud.json and the model selector is not shown.
OPENAI_API_KEY=[YOUR_API_KEY]ANTHROPIC_API_KEY=[YOUR_API_KEY]GOOGLE_GENERATIVE_AI_API_KEY=[YOUR_API_KEY]Vercel AI Gateway provides access to 200+ models through a single API.
AI_GATEWAY_API_KEY=[YOUR_AI_GATEWAY_API_KEY]Ollama enables you to run large language models locally on your own hardware.
OLLAMA_BASE_URL=http://localhost:11434When configured, Ollama models are discovered dynamically and appear in the model selector.
SearXNG can be used as an alternative search backend with advanced search capabilities. Docker Compose includes SearXNG automatically.
SEARCH_API=searxng
SEARXNG_API_URL=http://localhost:8080
SEARXNG_SECRET="" # generate with: openssl rand -base64 32# Search Behavior
SEARXNG_DEFAULT_DEPTH=basic # Set to 'basic' or 'advanced'
SEARXNG_MAX_RESULTS=50
SEARXNG_ENGINES=google,bing,duckduckgo,wikipedia
SEARXNG_TIME_RANGE=None # day, week, month, year, or None
SEARXNG_SAFESEARCH=0 # 0: off, 1: moderate, 2: strict
# Server
SEARXNG_PORT=8080
SEARXNG_BIND_ADDRESS=0.0.0.0
SEARXNG_IMAGE_PROXY=true
SEARXNG_LIMITER=falseSEARXNG_DEFAULT_DEPTH: Controls search depthbasic: Standard searchadvanced: Includes content crawling and relevance scoring
SEARXNG_CRAWL_MULTIPLIER: In advanced mode, determines how many results to crawl- Example: If
MAX_RESULTS=10andCRAWL_MULTIPLIER=4, up to 40 results will be crawled
- Example: If
Modify searxng-settings.yml to enable/disable specific search engines, change UI settings, or adjust server options. See the SearXNG documentation for details.
Brave Search provides enhanced support for video and image searches:
BRAVE_SEARCH_API_KEY=[YOUR_BRAVE_SEARCH_API_KEY]If not configured, type="general" searches fall back to your configured search provider.
By default, Morphic runs in anonymous mode (ENABLE_AUTH=false). This is ideal for personal, single-user environments.
ENABLE_AUTH=false
ANONYMOUS_USER_ID=anonymous-userAll users share a single anonymous user ID. No additional configuration needed.
For multi-user deployments:
-
Create a Supabase project at supabase.com
-
Set the following environment variables:
ENABLE_AUTH=true
NEXT_PUBLIC_SUPABASE_URL=[YOUR_SUPABASE_PROJECT_URL]
NEXT_PUBLIC_SUPABASE_ANON_KEY=[YOUR_SUPABASE_ANON_KEY]- Obtain your credentials from the Supabase dashboard:
- Project URL: Settings > API > Project URL
- Anon Key: Settings > API > Project API keys > anon/public
Guest mode allows users to try Morphic without creating an account. Guest sessions are ephemeral — no chat history is stored.
ENABLE_GUEST_CHAT=true- No authentication required
- No chat history saved
- Full context per request (client sends all messages)
- Disabled features: file upload, chat sharing, sidebar history
For cloud deployments:
GUEST_CHAT_DAILY_LIMIT=10 # Maximum requests per IP per day
UPSTASH_REDIS_REST_URL=[YOUR_UPSTASH_URL]
UPSTASH_REDIS_REST_TOKEN=[YOUR_UPSTASH_TOKEN]Rate limiting only applies when MORPHIC_CLOUD_DEPLOYMENT=true.
| Environment | Configuration |
|---|---|
| Personal/Local | ENABLE_AUTH=false (anonymous mode) |
| Public Demo | ENABLE_GUEST_CHAT=true with rate limiting |
| Production | ENABLE_AUTH=true (Supabase authentication) |
Enable tracing and monitoring with Langfuse:
LANGFUSE_SECRET_KEY=[YOUR_SECRET_KEY]
LANGFUSE_PUBLIC_KEY=[YOUR_PUBLIC_KEY]
LANGFUSE_HOST=https://cloud.langfuse.comEnable file upload with Cloudflare R2 or S3-compatible storage:
R2_ACCESS_KEY_ID=[YOUR_ACCESS_KEY]
R2_SECRET_ACCESS_KEY=[YOUR_SECRET_KEY]
R2_ACCOUNT_ID=[YOUR_ACCOUNT_ID] # For Cloudflare R2
# S3_ENDPOINT=[YOUR_S3_ENDPOINT] # Optional: generic S3-compatible endpoint
R2_BUCKET_NAME=[YOUR_BUCKET_NAME]
R2_PUBLIC_URL=[YOUR_PUBLIC_BASE_URL]If storage variables are not configured, /api/upload returns 400 and uploads are disabled.
Use Jina for enhanced content extraction:
JINA_API_KEY=[YOUR_API_KEY]