Learn AI · Guides
RAG Stack Under $100/mo
A production-capable retrieval stack for startups and side projects — ingestion, embeddings, vector store, LLM, and observability without enterprise bills.
Key takeaways
- 1pgvector on existing Postgres beats a separate vector DB under 1M chunks.
- 2Embedding cost is negligible — generation and bad retrieval dominate bills.
- 3Firecrawl saves weeks vs custom Playwright scrapers for web docs.
- 4Hybrid search (BM25 + vectors) is worth it when keyword match matters.
- 5Ship the docs chatbot workflow before buying Pinecone.
The stack
| Layer | Tool | Monthly cost |
|---|---|---|
| Ingestion | Firecrawl or markdown/git | $0-30 |
| Chunking | Python script or LlamaIndex loader | $0 |
| Embeddings | OpenAI text-embedding-3-small | $5-15 |
| Vector store | Supabase pgvector (free tier) | $0 |
| LLM | Claude Haiku retrieve+answer, Sonnet for hard queries | $40-60 |
| Observability | Langfuse self-host | $0 |
| Hosting | Vercel / Fly.io free tier | $0 |
| Total | $45-90/mo |
Layer 1 — Ingestion
Web docs: Firecrawl URL to markdown. Schedule weekly re-crawl for stale pages.
Git/markdown repo: Direct chunk from files — no crawl needed.
PDFs: pymupdf or unstructured.io locally.
Layer 2 — Embeddings
Default: text-embedding-3-small at 1536 dimensions.
Cost math: 1,200 doc pages at ~500 tokens/chunk, 3 chunks/page = 1.8M tokens. One-time embed under $0.50. Re-embed on change only.
Layer 3 — pgvector on Supabase
create extension vector;
create table chunks (
id bigserial primary key,
content text,
embedding vector(1536),
metadata jsonb
);
create index on chunks using hnsw (embedding vector_cosine_ops);
Store source_url, title, section in metadata for citations.
Upgrade to Qdrant or Pinecone when evals show retrieval latency problems at scale.
Layer 4 — Retrieval + generation
query
→ embed query
→ top-k similarity (k=8)
→ optional rerank (Cohere rerank or LLM pick top 3)
→ prompt with chunks + cite instructions
→ Haiku for default, Sonnet if confidence low
Layer 5 — Observability
Log every query in Langfuse:
- Retrieved chunk IDs
- Answer latency
- User thumbs down (feeds eval set)
The RAG docs case study hit $180/mo at production traffic — still under $100 for MVP volumes.
Cost control levers
- Cache embeddings — never re-embed unchanged docs
- Haiku default — Sonnet only on escalation
- Smaller k — start k=5, increase only if evals fail
- Query routing — FAQ keyword match before vector search
Build path
Follow Build an AI Docs Chatbot — it maps directly to this stack.
Upgrade path
| Signal | Upgrade |
|---|---|
| Retrieval p95 above 200ms | Qdrant or dedicated vector DB |
| Stale web docs | Firecrawl scheduled + diff re-index |
| Wrong answers persist | Hybrid search + reranker |
| Multi-tenant | Per-tenant namespaces in metadata |
Common misconceptions
The wrong-but-common takes worth correcting.
Myth
RAG requires Pinecone or Weaviate.
Reality
pgvector handles most MVP and early production loads. Migrate when filtering latency or scale demands it.
Myth
Bigger embeddings always help.
Reality
text-embedding-3-small at 1536 dims is the 2026 default. Upgrade dimensions only with eval evidence.
Real-world use cases
Frequently asked questions
Related on AIKnowHub
Concept
Chunking Strategies for RAG
Chunking is the highest-leverage decision in any RAG system. Get it wrong and no embedding model or vector DB will save you. Here's how to chunk by document type.
Concept
RAG Explained
Retrieval-Augmented Generation is how you give LLMs access to your own data without retraining them. Here's how it actually works.
Concept
Reranking & Hybrid Search
Embeddings alone miss exact terms. BM25 alone misses meaning. Hybrid search combines both, then a reranker picks the best. Here's how to build the retrieval stack that actually works.
Workflow
Build an AI Docs Chatbot
A RAG-powered chatbot that answers questions from your documentation with citations — the kind every SaaS site needs in 2026.
Comparison
Cheapest AI APIs
Per-million-token cost comparison across providers, with notes on where the cheap models are actually good enough.
Tool Guide
Dify Guide
The definitive guide to Dify for low-code AI apps — RAG chatbots, agent workflows, MCP import, self-host vs cloud, and when to pick it over Flowise or n8n.