use-apify.com
RAG: guides & tutorials
RAG grounds LLMs with fresh crawled chunks, not stale weights alone. Chunking, embeddings, and Apify crawlers feeding vector DBs with clean markdown.
15 articlesPage 1 of 2
View all tags
Retrieval-augmented generation grounds LLMs in fresh, crawled content instead of stale training weights. These guides cover the RAG pipeline end to end: crawling sources, chunking, embedding, and feeding vector databases with clean markdown.
Quality retrieval starts with quality ingestion, well-chunked, deduplicated, current data. Apify crawlers supply that input and keep it refreshed. Below you will find tutorials on building RAG corpora and keeping them up to date.

TL;DR
- One
docker-compose.yml: Dify (API + worker + web + sandbox) + Qdrant + Ollama + PostgreSQL + Redis + Caddy
- Measured idle RAM: ~7.4 GB (Llama 3 8B loaded, CPU inference); minimum server: 16 GB VPS
- Replaces: OpenAI Assistants API ($0.03/1k tokens) + Pinecone Starter ($70/mo) with a fully local, zero-egress alternative
- Your documents never leave the server — not during upload, not during embedding, not during inference
Retrieval-Augmented Generation (RAG) lets you ask questions against a private document corpus and get answers grounded in the actual content. The dominant hosted pattern — OpenAI Assistants + Pinecone — works, but every document chunk and every query travels to OpenAI's servers. For legal contracts, internal knowledge bases, or any non-public data, that is a compliance liability.
This guide deploys a fully self-hosted RAG stack: Dify as the orchestration and document management layer, Qdrant as the vector database, and Ollama serving both the embedding model and the chat LLM — all on a single Liquid Web VPS.

A production RAG (retrieval-augmented generation) system crawls your content, splits it into section-sized chunks, embeds them in a vector database, retrieves and reranks the best matches for each question, and has an LLM answer only from those matches, with citations. Most RAG projects that disappoint in production get the model right and the plumbing wrong: chunks that cut sections in half, no reranking, and an index that silently goes stale.
This guide builds each stage with ready-to-run Python, and spends most of its time on the parts other guides skip: chunking, freshness and measurement.
| Stage | Tool | Key decision |
|---|
| 1. Crawl | Apify Website Content Crawler | Clean Markdown per page, on a schedule |
| 2. Chunk | Markdown RAG Chunker or LangChain | One section per chunk, ≤512 tokens, stable IDs |
| 3. Embed | OpenAI text-embedding-3-small or local FastEmbed | Cost vs quality |
| 4. Store | Qdrant or pgvector | Dedicated vector DB vs your existing Postgres |
| 5. Retrieve | Dense search + Cohere rerank-v4.0-pro | Top 20 candidates, rerank to top 5 |
| 6. Generate | Claude (claude-opus-5-5) | Answer only from sources, cite them |
| 7. Stay fresh | Stable chunk IDs + document_hash cleanup | Re-embed only what changed |
Install everything (latest stable versions as of October 2026; the code below targets them):
pip install apify-client==3.3.0 langchain-text-splitters==1.1.3 tiktoken==0.14.0 \
openai==3.35.1 fastembed==0.9.0 qdrant-client==1.19.1 cohere==7.2.0 anthropic==1.15.0
You need an Apify account, a Qdrant instance (docker run -p 6333:6333 qdrant/qdrant, or Qdrant Cloud's free tier), and API keys for the services you choose: OpenAI (optional), Cohere and Anthropic.

Short answer: Jina Reader turns one URL into Markdown with a single GET request (https://r.jina.ai/<url>) and works without an API key at 20 requests a minute. Firecrawl is a credit-billed API, with an AGPL-3.0 engine you can self-host, that adds site crawling, URL mapping and schema-based JSON extraction; its cloud also allows keyless single-page scrapes under a daily per-IP cap, but crawling needs a key. Use Jina Reader to drop a page into a prompt; use Firecrawl to turn a whole site into a RAG index.
Prices, rate limits, headers and API versions on this page were checked against jina.ai and firecrawl.dev on 25 November 2026. Jina Reader's keyless behaviour and headers were tested the same day; the Firecrawl samples are quoted from its docs.

To build a RAG knowledge base from a website with Firecrawl, you run six steps: map the site's URLs, crawl the pages to Markdown, split the Markdown into chunks, embed each chunk, store the vectors with their source URL, and retrieve the closest chunks for each question. Firecrawl handles the first two steps. Chunking is the step that most affects answer quality, and it is the one Firecrawl leaves to you.
This guide gives you a tested Python pipeline for all six steps with the current Firecrawl SDK, plus two ways to chunk: a free local splitter and a header-aware chunker that adds section paths and stable IDs.

Feeding live web pages into an LLM or a RAG index sounds simple until you look at the token math. Raw HTML for a typical docs or product page can blow past 100,000 tokens once you count inline CSS, SVG, trackers, and nested <div>s—while the sentences you actually care about might sit closer to 3,000.
Shipping that HTML straight into inference burns latency and context budget, and it tends to bury the important lines—the familiar “lost in the middle” problem.
This guide compares the old playbook (sanitize HTML yourself) with API-first Markdown extraction aimed at chunking and embeddings, without changing the underlying tradeoffs.