PromptsApr 2, 2026·3 min read

Morphic — Open-Source AI Answer Engine

Perplexity-style AI search with generative UI. Multiple LLM and search providers. Self-hostable with Next.js. 8.7K+ stars.

TO
TokRepo精选 · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

```bash git clone https://github.com/miurla/morphic.git cd morphic docker compose up -d ``` Open `http://localhost:3000` — your AI search engine is live. Or for local development: ```bash git clone https://github.com/miurla/morphic.git cd morphic cp .env.local.example .env.local # Edit .env.local with your API keys npm install npm run dev ``` Required environment variables: ```env OPENAI_API_KEY=sk-... # Or ANTHROPIC_API_KEY, GOOGLE_API_KEY TAVILY_API_KEY=tvly-... # Or use SearXNG (free, self-hosted) SEARXNG_API_URL=http://localhost:8080 # Free alternative to Tavily DATABASE_URL=postgresql://... # For chat history REDIS_URL=redis://localhost:6379 ``` ---
Intro
Morphic is an open-source AI-powered answer engine with 8,700+ GitHub stars that delivers a Perplexity-like search experience you can self-host. Built with Next.js and the Vercel AI SDK, it combines LLM providers (OpenAI, Anthropic, Google, Ollama) with search backends (Tavily, SearXNG, Brave, Exa) to generate comprehensive, cited answers with a beautiful generative UI. Features include a dynamic model selector, persistent chat history in PostgreSQL, shareable result URLs, and Docker-based one-command deployment. Works with: OpenAI, Anthropic Claude, Google Gemini, Ollama (local), Tavily, SearXNG, Brave Search. Best for teams wanting a private, customizable AI search engine. Setup time: under 5 minutes with Docker. ---
## Morphic Architecture & Features ### How It Works ``` User Query: "What are the latest advances in protein folding?" │ ├─ 1. Search Phase │ SearXNG/Tavily searches the web │ Returns 10-20 relevant sources │ ├─ 2. AI Synthesis │ LLM reads all sources │ Generates comprehensive answer │ Adds inline citations [1][2][3] │ ├─ 3. Generative UI │ Renders answer with rich formatting │ Shows source cards with thumbnails │ Suggests follow-up questions │ └─ 4. Persistence Saves to PostgreSQL Shareable via unique URL ``` ### Multiple Search Providers | Provider | Type | Cost | Setup | |----------|------|------|-------| | **SearXNG** | Self-hosted | Free | Docker container | | **Tavily** | API | Freemium | API key | | **Brave** | API | Freemium | API key | | **Exa** | API | Paid | API key | SearXNG is recommended for self-hosting — free, no rate limits, 70+ search engines. ### Multiple LLM Providers Switch models on the fly with the built-in model selector: | Provider | Models | Setup | |----------|--------|-------| | **OpenAI** | GPT-4o, GPT-4o-mini | API key | | **Anthropic** | Claude Sonnet, Claude Haiku | API key | | **Google** | Gemini Pro, Gemini Flash | API key | | **Ollama** | Llama 3, Mistral, Qwen | Local install | | **Vercel Gateway** | Routes to cheapest/fastest | Vercel config | ### Generative UI Morphic renders rich, interactive answer pages: - **Cited text** — Inline numbered citations linking to sources - **Source cards** — Thumbnails and metadata for each referenced page - **Follow-up suggestions** — AI-generated related questions - **Image results** — Relevant images from search - **Code blocks** — Syntax-highlighted code in answers - **Math rendering** — LaTeX formulas displayed correctly ### Chat History & Sharing ``` PostgreSQL stores: ├─ User sessions ├─ Search queries ├─ Generated answers ├─ Source citations └─ Shareable URLs (e.g., /search/abc123) ``` ### Self-Hosting with SearXNG The most cost-effective setup — completely free: ```yaml # docker-compose.yaml (included in repo) services: morphic: build: . ports: ["3000:3000"] environment: - SEARXNG_API_URL=http://searxng:8080 - OPENAI_API_KEY=${OPENAI_API_KEY} - DATABASE_URL=postgresql://postgres:password@db:5432/morphic searxng: image: searxng/searxng ports: ["8080:8080"] db: image: postgres:16-alpine environment: - POSTGRES_DB=morphic - POSTGRES_PASSWORD=password redis: image: redis:alpine ``` --- ## FAQ **Q: What is Morphic?** A: Morphic is an open-source AI answer engine with 8,700+ GitHub stars — a self-hostable Perplexity alternative built with Next.js, supporting multiple LLM providers and search backends with a generative UI. **Q: How much does it cost to run Morphic?** A: Infrastructure is free (Docker + SearXNG). You only pay for LLM API calls (~$0.01-0.05 per query with GPT-4o-mini). Use Ollama for completely free local inference. **Q: Is Morphic free?** A: Yes, open-source under Apache-2.0. Self-host for free. Only LLM API costs apply (or use Ollama for free local models). ---
🙏

Source & Thanks

> Created by [miurla](https://github.com/miurla). Licensed under Apache-2.0. > > [morphic](https://github.com/miurla/morphic) — ⭐ 8,700+ Thanks to miurla for building the best open-source alternative to Perplexity AI.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets