To build a RAG chatbot with Haystack, install haystack-ai, split documents into chunks, embed them, and write them to a document store. For each question, embed the question with the same model, retrieve the closest chunks, build a grounded prompt, and send it to a chat generator. Haystack is free under Apache-2.0; deepset Studio is $0 for limited prototyping.
A chatbot that answers from your own documents sounds simple until it quotes last year’s refund policy with total confidence. The model is usually not the first problem. The weak point is the path between your files and the answer: messy chunks, the wrong passage retrieved, no source shown, and no test that proves the bot can say “I don’t know.”
This guide shows how to build a RAG chatbot with Haystack, deepset’s open-source Python framework for retrieval-augmented generation. You will build two pipelines: one that indexes documents and one that answers questions from them. Then you will add the parts demos skip: grounded prompts, evaluation, deployment, security, backups, and a cost test.
Quick Answer
To build a RAG chatbot with Haystack, install haystack-ai, split your documents into searchable chunks, embed those chunks, and write them to a document store. For each question, embed the question with the same embedding model, retrieve the closest chunks, place them in a ChatPromptBuilder template, and send that prompt to a chat generator. Haystack is free under Apache-2.0; deepset Studio is $0 for limited prototyping, while production Enterprise pricing is custom.
In this article
- How we checked this guide
- What Haystack replaces, and what it does not
- How a Haystack RAG chatbot works
- Self-hosted Haystack, deepset Studio, or Enterprise
- Requirements before you build a RAG chatbot
- Step 1: install Haystack and the local embedding integration
- Step 2: build the indexing pipeline
- Step 3: choose a document store for production
- Step 4: build the RAG query pipeline
- Step 5: make answers grounded, cited, and able to refuse
- Step 6: test retrieval before you trust the chatbot
- Step 7: deploy the chatbot with Hayhooks
- First-run security steps you must not skip
- Backup and update routine
- Common errors and fixes
- Tips and tricks that save money
- The real cost maths
- When not to self-host a Haystack chatbot
- Pros and cons
- Our verdict
- FAQ
- Strategic Pivot
- Sources
How we checked this guide
We checked licence, installation, indexing, retrieval, evaluation, serialization, and deployment in official Haystack documentation and tutorials on December 2, 2026. We checked platform limits on deepset’s official pricing page and model-token rates on OpenAI’s official pricing page the same day.
What Haystack replaces, and what it does not
Haystack replaces the glue code you would otherwise write between document converters, splitters, embedders, retrievers, prompt builders, generators, and evaluators. Instead of hiding that flow inside one long script, you connect named components into pipelines. When an answer is wrong, you can inspect which component failed: conversion, chunking, retrieval, prompting, or generation.

That explicit structure is the main reason to choose Haystack. A finished document-chat app may be faster to launch, but it decides many details for you. Haystack lets you decide which files enter the index, how chunks keep their source metadata, which retriever runs, what the prompt forbids, and how answers are tested.
Haystack is open source under Apache-2.0. In plain words, you may use, copy, modify, and distribute it without a licence fee, subject to the licence terms. The framework licence cost is $0. Your server, model provider, document store, backups, monitoring, and admin time still cost money.
Haystack does not replace your documents. If a PDF converts into broken text, if tables lose their headings, or if two policy versions sit in the index, the chatbot will retrieve bad evidence quickly. It also does not replace the language model. You still choose a hosted API model or a local model, and that choice affects cost, privacy, latency, and answer quality.
Best for: a small-business owner, freelancer, or technical operator who wants a chatbot over business documents and needs control over retrieval, prompts, sources, and deployment. Skip if: you want a no-code finished chatbot today, you have no Python help, or your documents are not clean enough to index yet.
If you want the finished application first, our guide to install AnythingLLM to chat with business documents covers a ready-made workspace. Choose AnythingLLM when the workspace is the product. Choose Haystack when the chatbot is a feature inside your own product, website, support flow, or internal tool.
How a Haystack RAG chatbot works
A RAG chatbot has two separate jobs. The indexing pipeline prepares knowledge. The query pipeline answers questions. Mixing those jobs into one script is how stale documents and mystery answers start.
The indexing pipeline converts files into Haystack Document objects, cleans them, splits them into chunks, creates embeddings, and writes the chunks to a document store. Each chunk should keep metadata such as source file, title, section, version, date, customer, product, or permission group. Metadata is not decoration. It is how the chatbot avoids mixing a current policy with an archived one.
The query pipeline starts when a user asks a question. A text embedder turns the question into a vector with the same embedding model used for documents. A retriever searches the document store for close chunks. A prompt builder inserts those chunks and the question into a chat template. A chat generator writes the answer.
The answer is only as good as the retrieved chunks. If the right chunk is not retrieved, a stronger model cannot invent it safely. If the right chunk is retrieved but the prompt allows guessing, the model may still add facts that are not in your documents. That is why this guide treats retrieval testing and refusal behaviour as core build steps, not polish.
Haystack’s component model makes those steps visible. Converters handle file types. DocumentSplitter creates chunks. Embedders create vectors. Retrievers fetch documents. ChatPromptBuilder builds the prompt. Chat generators call the model. Evaluators score retrieval and faithfulness. Hayhooks can serve the finished pipeline as an HTTP endpoint.
Self-hosted Haystack, deepset Studio, or Enterprise
You have three practical routes. The right one depends on whether this chatbot is a prototype, a private internal tool, or a customer-facing product with access controls.
| Route | Licence or base price | Best for | Main limit |
|---|---|---|---|
| Self-hosted Haystack | $0 licence fee, Apache-2.0 | Your own app, private data, custom retrieval and prompts | You own hosting, security, backups, updates, monitoring, and model costs |
| deepset Studio | $0 | One person prototyping | 1 workspace, 1 user, 100 pipeline hours, 50 files up to 10MB each, 2 development pipelines |
| deepset Enterprise | Custom | Teams that need production pipelines, SSO, RBAC, and support | No public dollar price; budget through a sales quote |
Self-hosting is the lean route when you already have a server and someone who can maintain Python services. Studio is useful for a first prototype, but its file and pipeline-hour limits make it a poor production plan. Enterprise is the managed route when governance and support matter more than avoiding a platform bill.
Requirements before you build a RAG chatbot
Use Python 3.11 or newer for current Haystack releases. Create a clean virtual environment so Haystack, integration packages, and your application dependencies do not collide with another project.
Prepare a small test folder before you index the whole business. Ten clean documents beat ten thousand messy files. Include one policy with a clear answer, one product page, one document with a table, one outdated document you will exclude, and one question your documents cannot answer. That last case matters: the chatbot must learn to refuse.
Decide the embedding route before indexing. This guide uses Sentence Transformers locally, with sentence-transformers/all-MiniLM-L6-v2, because Haystack’s official RAG tutorial uses the same model for documents and questions. Local embeddings keep document text on your machine during indexing, but the model still needs CPU or GPU time. If you switch embedding models later, re-index the corpus; vectors from different models do not belong in the same search space.
Decide the answer model separately. Haystack can call hosted chat generators or local models. A hosted API is easier to start and bills by tokens. A local model avoids per-token API bills but needs hardware and operations. Our guide to install Ollama on Ubuntu covers one local model route.
Finally, decide who may ask questions. A public website bot, a staff-only assistant, and a customer-account assistant need different retrieval filters. If documents have permissions, those permissions must be enforced before retrieval, not after the answer is written.
Step 1: install Haystack and the local embedding integration
Install Haystack with pip:
python -m venv .venv
source .venv/bin/activate
pip install haystack-ai
pip install sentence-transformers-haystack
pip install markdown-it-py mdit_plain pypdfThe core package is haystack-ai. The Sentence Transformers embedders live in the sentence-transformers-haystack integration package. The extra packages support Markdown and PDF conversion in the indexing example.
If Haystack reports a missing optional dependency, install the package named in the error and run the same command again. Haystack keeps optional dependencies out of the core install, so a missing converter package is normal, not a broken installation.
Create a project layout that separates code, documents, and generated pipeline files:
rag-chatbot/
documents/
pipelines/
index_documents.py
ask_question.py
requirements.txtPin the versions you tested in requirements.txt. A RAG chatbot is a chain of moving parts; unpinned upgrades can change converter behaviour, component imports, or model defaults while your documents stay the same.
Step 2: build the indexing pipeline
The indexing pipeline routes each file type to the right converter, cleans the text, splits it into chunks, embeds the chunks, and writes them to the document store. Haystack’s official file-type tutorial uses FileTypeRouter, converters for text, Markdown, and PDF, DocumentCleaner, DocumentSplitter, SentenceTransformersDocumentEmbedder, and DocumentWriter.
Start with InMemoryDocumentStore for the first test. It needs no external service and is easy to debug. Do not mistake it for production storage: it is ephemeral and does not scale like a real document store.
from pathlib import Path
from haystack import Pipeline
from haystack.components.converters import MarkdownToDocument, PyPDFToDocument, TextFileToDocument
from haystack.components.preprocessors import DocumentCleaner, DocumentSplitter
from haystack.components.routers import FileTypeRouter
from haystack.components.writers import DocumentWriter
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack_integrations.components.embedders.sentence_transformers import SentenceTransformersDocumentEmbedder
document_store = InMemoryDocumentStore()
indexing = Pipeline()
indexing.add_component("router", FileTypeRouter(mime_types=["text/plain", "application/pdf", "text/markdown"]))
indexing.add_component("text_converter", TextFileToDocument())
indexing.add_component("markdown_converter", MarkdownToDocument())
indexing.add_component("pdf_converter", PyPDFToDocument())
indexing.add_component("cleaner", DocumentCleaner())
indexing.add_component("splitter", DocumentSplitter(split_by="word", split_length=150, split_overlap=50))
indexing.add_component("embedder", SentenceTransformersDocumentEmbedder(model="sentence-transformers/all-MiniLM-L6-v2"))
indexing.add_component("writer", DocumentWriter(document_store))
indexing.connect("router.text/plain", "text_converter.sources")
indexing.connect("router.application/pdf", "pdf_converter.sources")
indexing.connect("router.text/markdown", "markdown_converter.sources")
indexing.connect("text_converter", "cleaner")
indexing.connect("markdown_converter", "cleaner")
indexing.connect("pdf_converter", "cleaner")
indexing.connect("cleaner", "splitter")
indexing.connect("splitter", "embedder")
indexing.connect("embedder", "writer")
files = list(Path("documents").glob("**/*"))
indexing.run({"router": {"sources": files}})
print("Indexed documents:", document_store.count_documents())The splitter settings above follow Haystack’s tutorial pattern: 150-word chunks with 50 words of overlap. Treat those numbers as a starting test, not a law. Policy clauses, product manuals, and support macros may need different chunk sizes. Read twenty random chunks after indexing. If a chunk cannot be understood without the page around it, your splitter is cutting meaning in half.
Add metadata before writing documents. At minimum, keep the source path or URL, document title, section heading, version, and last-updated date. For customer data, add tenant, account, product, language, and permission fields. Retrieval filters can only use fields you stored.
Step 3: choose a document store for production
The in-memory store proves the pipeline. Production needs persistence, backups, filtering, and a retrieval method that matches your questions.

Use pgvector when PostgreSQL already holds the business records your chatbot must respect. Our guide to use pgvector for AI search in PostgreSQL covers that route. Use Qdrant when payload filtering and a dedicated vector service matter; see install Qdrant vector database with Docker. Use Chroma for an embedded-first Python route; see install Chroma vector database for RAG apps. Use Weaviate when hybrid keyword-plus-vector search and object-style data fit the job; see install Weaviate self hosted vector search. Use Milvus when scale headroom is the main requirement; see install Milvus vector database.
Do not choose by benchmark alone. Ask four buyer questions. Does the store support the filters your permissions need? Can you back it up and restore it? Does it support keyword or hybrid search for exact product codes and policy numbers? Can your team operate it after the demo?
Vector search is strong on meaning and weak on exact strings. Product codes, invoice numbers, error IDs, names, and version numbers often need keyword search beside embeddings. If your users ask exact-term questions, plan hybrid retrieval or a reranking step instead of blaming the chat model.
Step 4: build the RAG query pipeline
The query pipeline embeds the question, retrieves documents, builds a prompt, and calls the chat generator. The question embedder must use the same model as the document embedder.

import os
from haystack import Pipeline
from haystack.components.builders import ChatPromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
from haystack.dataclasses import ChatMessage
from haystack_integrations.components.embedders.sentence_transformers import SentenceTransformersTextEmbedder
template = [
ChatMessage.from_user(
"""
Answer only from the context below. If the context does not contain the answer, say: I don't know from the provided documents.
Cite the source title or file name for each factual claim.
Context:
{% for document in documents %}
Source: {{ document.meta.get("source", "unknown") }}
{{ document.content }}
{% endfor %}
Question: {{ question }}
Answer:
"""
)
]
rag = Pipeline()
rag.add_component("embedder", SentenceTransformersTextEmbedder(model="sentence-transformers/all-MiniLM-L6-v2"))
rag.add_component("retriever", InMemoryEmbeddingRetriever(document_store=document_store, top_k=5))
rag.add_component("prompt_builder", ChatPromptBuilder(template=template, required_variables="*"))
rag.add_component("llm", OpenAIChatGenerator(model=os.environ.get("OPENAI_MODEL", "gpt-4o-mini")))
rag.connect("embedder.embedding", "retriever.query_embedding")
rag.connect("retriever", "prompt_builder.documents")
rag.connect("prompt_builder.prompt", "llm.messages")
question = "What is the refund window for damaged items?"
result = rag.run({"embedder": {"text": question}, "prompt_builder": {"question": question}})
print(result["llm"]["replies"][0].text)Set OPENAI_API_KEY in the environment before running the OpenAI example. Do not paste the key into code, screenshots, or pipeline YAML. If you use a local generator instead, replace the chat generator component and keep the retriever, prompt, and evaluation steps the same.
Run the pipeline with a question whose answer is in one document. Then run a question whose answer is absent. The first should cite the right source. The second should refuse. If the second produces a smooth guess, fix the prompt and retrieval threshold before adding more documents.
Step 5: make answers grounded, cited, and able to refuse
A RAG prompt should not ask the model to be helpful in general. It should give the model a narrow job: answer from retrieved context, cite sources, and stop when the context is insufficient.
Use three rules in the prompt. First, answer only from the provided context. Second, name the source for factual claims. Third, use a fixed refusal sentence when the answer is missing. A fixed refusal is easier to log, test, and show to users than ten creative apologies.
Keep retrieved context small enough to inspect. Five chunks are a reasonable first test. More chunks can help recall, but they also add noise, cost, and conflicting passages. If the right chunk ranks eighteenth, the fix is better retrieval or reranking, not stuffing twenty chunks into every prompt.
Show sources in the product, not only in the prompt. Store the document title, source path, section, and updated date in metadata, then render those fields beside the answer. A citation that points to the wrong section is worse than no citation because it teaches users to distrust the system.
Handle follow-up questions carefully. A chatbot may need conversation history, but history should not override current documents. It should still retrieve fresh evidence before answering.
Step 6: test retrieval before you trust the chatbot
Build a test set before launch. Start with 30 to 50 real questions. For each one, record the expected answer, the document that contains it, and whether the chatbot should refuse. Include exact-term questions, policy questions, product questions, and questions with no answer in the corpus.
Measure retrieval and generation separately. Retrieval passes when the correct chunk appears in the retrieved results. Generation passes when the final answer is supported by that chunk. If retrieval fails, fix parsing, chunking, metadata, embeddings, filters, or reranking. If retrieval passes and generation fails, fix the prompt, model choice, or context size.
Haystack includes evaluators for both sides. DocumentRecallEvaluator, DocumentMRREvaluator, DocumentMAPEvaluator, and DocumentNDCGEvaluator score retrieved documents when you have labels. ContextRelevanceEvaluator checks whether retrieved context is relevant. FaithfulnessEvaluator checks whether generated statements can be inferred from the provided contexts.
Run the test set after every change: new documents, new splitter settings, new embedding model, new retriever, new prompt, new generator. A change that improves one demo answer can quietly break ten policy answers. The test set turns that risk into a number you can see.
Log declined questions. They show where documents are missing, where wording is unclear, and where users expect the bot to know something the business has not written down. Review those logs weekly at first. A RAG chatbot improves when the knowledge base improves, not only when the prompt changes.
Step 7: deploy the chatbot with Hayhooks
Hayhooks serves Haystack pipelines through HTTP endpoints. Install it with pip, start the server, deploy a pipeline wrapper, and call the pipeline endpoint from your website or app.
pip install hayhooks
hayhooks runA Hayhooks deployment uses a pipeline definition and a pipeline_wrapper.py file. The wrapper loads the pipeline and defines run_api, the method your HTTP endpoint calls.
from pathlib import Path
from haystack import Pipeline
from hayhooks import BasePipelineWrapper
class PipelineWrapper(BasePipelineWrapper):
def setup(self) -> None:
pipeline_yaml = (Path(__file__).parent / "pipeline.yml").read_text()
self.pipeline = Pipeline.loads(pipeline_yaml)
def run_api(self, question: str) -> str:
result = self.pipeline.run(
{"embedder": {"text": question}, "prompt_builder": {"question": question}}
)
return result["llm"]["replies"][0].textDeploy the files with Hayhooks:
hayhooks pipeline deploy-files -n rag_chatbot rag_chatbot_dirThen call the deployed pipeline at its {pipeline_name}/run endpoint. Hayhooks also supports OpenAI-compatible chat endpoints through run_chat_completion, which helps when a chat UI expects that interface.
Do not expose a raw development server to the public internet. Put the service behind your normal application controls: authentication, rate limits, request-size limits, logging, and a reverse proxy or platform gateway. A chatbot endpoint that can call a paid model is a billing surface as well as a search surface.
First-run security steps you must not skip
Keep API keys in environment variables or a secret manager. Rotate any key that appears in a screenshot, log, issue, or shared pipeline file. Give the chatbot service its own key with the lowest limits that still allow production traffic, so a runaway loop cannot spend the whole account.
Filter documents by permission before retrieval. If a staff document and a public document share an index, the retriever must know which user is asking. Test with two accounts: one that may see the document and one that may not. The second account must not receive the answer, the citation, or a hint that the document exists.
Treat uploaded documents as untrusted input. Validate file types, limit file size, scan where your policy requires it, and parse in a worker that cannot reach unrelated systems. A PDF is data, not instructions for your server.
Review telemetry and tracing settings before production. Haystack’s README says it collects anonymous usage statistics of pipeline components and links to opt-out documentation. If your policy forbids usage events leaving the machine, set the documented opt-out in the deployment environment and restart the service.
Protect pipeline YAML like code. Haystack serialization can save pipelines to YAML and load them later. Loading a pipeline instantiates classes named in the serialized data, and Haystack gates deserialization with a trusted-module allowlist. Only load pipeline files you wrote or reviewed. Never use an unsafe bypass for YAML from an untrusted source.
Log questions, retrieved document IDs, model name, token usage, latency, and refusal status. Do not log secrets. Be careful with personal data in questions and documents; set a retention period and tell users what is stored.
Backup and update routine
Back up four things: source documents, document-store data, pipeline YAML, and configuration. Source documents let you rebuild the index. Document-store backups save time. Pipeline YAML records component choices. Configuration records model names, store endpoints, and non-secret settings.
Test restore before launch. Rebuild the index into a clean store, run the test set, and confirm the same questions retrieve the same sources. A backup that cannot rebuild the chatbot is only a folder of files.
Update Haystack and integrations in a staging environment first. Pin versions, read release notes for breaking changes, run indexing on a sample corpus, and run the evaluation set. Promote the update only when retrieval and faithfulness scores stay acceptable.
Re-index when documents change. Store version and updated-date metadata with every chunk. When a policy changes, remove or supersede the old chunks before adding the new ones. Two versions of the same rule in one index will produce confident contradictions.
Keep the embedding model stable inside one index. If you change the embedding model, create a new index, embed every chunk again, run the test set, and switch traffic only after the new index passes. Mixing vectors from two models makes similarity scores meaningless.
Common errors and fixes
The chatbot answers, but the source is wrong. Check retrieval first. Print the retrieved chunks for that question. If the right chunk is absent, fix chunking, metadata, filters, or the embedding model. If the right chunk is present but ranked low, add hybrid retrieval or reranking.
The chatbot says it does not know, but the answer exists. Inspect the parsed text. PDFs often convert tables, headers, and columns badly. If the indexed text is broken, retrieval cannot find the answer. Fix conversion before changing the model.
Exact product codes fail. Vector search understands meaning better than exact strings. Add keyword or hybrid retrieval for SKUs, error codes, invoice numbers, names, and version numbers. Keep metadata filters for product, status, language, and permission.
The answer mixes old and new policy. Your index contains both versions without a reliable version filter. Add version and updated-date metadata, remove superseded chunks, and re-index. Do not ask the model to guess which policy is current.
Pipeline loading fails after saving YAML. Check the deserialization allowlist. Custom components outside Haystack’s trusted modules must be allowed explicitly. Review the YAML before allowing a module; the allowlist exists to stop crafted files from instantiating arbitrary classes.
Costs rise after launch. Count input tokens, not only questions. Long prompts, large retrieved contexts, retries, and evaluation runs all bill. Reduce top-k, shorten chunks, cache repeated answers where policy allows, and set provider spend alerts.
Tips and tricks that save money
Start with local embeddings when document text should stay on your machine during indexing. You still pay for compute, but you avoid sending every chunk to an embedding API. Keep the same embedding model for documents and questions.
Use the smallest chat model that passes your test set. A larger model cannot repair missing retrieval. Spend first on clean documents, metadata, and evaluation; then compare models on the same questions.
Retrieve fewer, better chunks. A reranker can take a larger candidate set and pass the best few to the prompt. That can improve answers while keeping prompt tokens under control.
Write refusal logs into product work. If users repeatedly ask about shipping regions your documents do not cover, the cheapest fix may be a better help page, not a bigger model.
The real cost maths
Haystack’s licence cost is $0. That does not make the chatbot free. The bill moves to model tokens, hosting, document storage, monitoring, and the person who keeps documents current.

Use this token formula for an API model:
monthly model cost =
questions × ((input tokens per question ÷ 1,000,000 × input rate)
+ (output tokens per question ÷ 1,000,000 × output rate))Take a small support chatbot with 5,000 questions a month. Assume each answer sends 2,000 input tokens, including retrieved context, and returns 300 output tokens. That is 10,000,000 input tokens and 1,500,000 output tokens a month.
OpenAI’s pricing page checked on December 2, 2026 listed gpt-6.2-sol at $2.00 input and $10.00 output per 1M tokens. At those rates, input costs $20.00 and output costs $15.00. The model bill is $35.00 a month, or $420.00 a year, before hosting, storage, retries, evaluation runs, and admin time.
If your Haystack generator uses another model, replace the two rates and keep the token maths. If you run a local model, the per-token API line can fall to $0, but the cost moves to hardware, electricity, latency, and maintenance.
Compare that with deepset Studio. Studio is $0, but it is limited to 1 workspace, 1 user, 100 pipeline hours, 50 files up to 10MB each, and 2 development pipelines. That fits a prototype. It does not price a production support bot. Enterprise is custom, so any saving claim against Enterprise needs a written quote.
The lean self-hosted stack is Haystack, local embeddings, a document store you already operate, and a modest API model. The full stack adds managed document storage, reranking, tracing, evaluation runs, backups, and support. The lean stack wins on cash. The full stack wins when wrong answers cost more than infrastructure.
When not to self-host a Haystack chatbot
Do not self-host when nobody can own Python services, document updates, backups, and incident response. A chatbot that answers from stale policy is not a saving; it is a liability with a chat window.
Do not self-host when your documents are not ready. If source files are scanned images, duplicated policies, or screenshots of tables, fix document preparation first. Haystack can index text; it cannot make unclear business rules clear.
Do not self-host a public bot without rate limits and spend alerts. Every question can trigger embedding, retrieval, and model calls. Abuse and retry loops turn a small token bill into a surprise.
Choose a finished document-chat product when speed matters more than control. Choose deepset Enterprise or another managed platform when SSO, RBAC, support, and production operations are the buying reasons. Choose Haystack when retrieval quality, source control, and deployment inside your own stack are worth operating the system.
Pros and cons
Pros
- Free Apache-2.0 framework with no Haystack licence fee.
- Explicit pipelines make indexing, retrieval, prompting, generation, and evaluation inspectable.
- Works with local embeddings, hosted models, local models, and many document stores.
- Built-in evaluators help measure retrieval quality and answer faithfulness.
- Hayhooks can serve pipelines as HTTP endpoints, including OpenAI-compatible chat routes.
Cons
- You must operate Python services, document storage, backups, updates, and monitoring.
- Retrieval quality depends on document preparation, chunking, metadata, and embedding choices.
- API model costs scale with questions, context size, retries, and evaluation runs.
- Permissions must be designed into retrieval; Haystack does not make unsafe document access safe by itself.
- A finished document-chat app is faster when you do not need custom control.
Our verdict
Build a RAG chatbot with Haystack when you need control over the evidence path: which documents enter the index, which chunks are retrieved, what the prompt allows, and how answers are tested. Start with a small corpus, local embeddings, five retrieved chunks, cited answers, and a refusal test. Move to a persistent document store only after retrieval passes your test set.
Skip Haystack when you need a finished chatbot today or when nobody will maintain documents and infrastructure. The framework is free. A trustworthy chatbot is not.
FAQ
Is Haystack free for a RAG chatbot?
Yes. Haystack is open source under Apache-2.0, so the framework licence fee is $0. You still pay for hosting, document storage, model usage or local hardware, backups, monitoring, and admin time.
Do I need a vector database to build a RAG chatbot with Haystack?
No. You can start with Haystack’s in-memory document store for a prototype. For production, use a persistent document store such as pgvector, Qdrant, Chroma, Weaviate, Milvus, or another supported store that fits your filters, backups, and scale.
Why does my RAG chatbot still hallucinate?
Usually because retrieval returned the wrong chunks, the chunks were stale or badly split, or the prompt allowed the model to answer beyond the context. Test retrieval separately from generation, require citations, and give the model a fixed refusal sentence.
Can Haystack use a local model instead of OpenAI?
Yes. Haystack supports hosted providers and local or self-hosted model routes through chat generator integrations. The retriever, prompt builder, and evaluation steps stay similar; the generator component changes.
How much does a Haystack RAG chatbot cost?
The Haystack licence is $0. In our worked example, 5,000 questions a month at 2,000 input tokens and 300 output tokens per answer cost $35.00 a month at OpenAI’s checked gpt-6.2-sol rates, before hosting, storage, retries, evaluation, and admin time.
Strategic Pivot
Before you commit to a model or document store, price the whole stack, not only the licence. Use our AI Cost Calculator to compare the lean self-hosted route with a managed platform once you have your monthly question count, token estimate, and hosting cost.
Sources
- Haystack installation documentation: https://docs.haystack.deepset.ai/docs/installation
- Haystack first RAG pipeline tutorial: https://haystack.deepset.ai/tutorials/27_first_rag_pipeline
- Haystack file-type preprocessing tutorial: https://haystack.deepset.ai/tutorials/30_file_type_preprocessing_index_pipeline
- Haystack document store guide: https://docs.haystack.deepset.ai/docs/choosing-a-document-store
- Haystack evaluation documentation: https://docs.haystack.deepset.ai/docs/evaluation
- Haystack Hayhooks documentation: https://docs.haystack.deepset.ai/docs/hayhooks
- Haystack pipeline serialization documentation: https://docs.haystack.deepset.ai/docs/serialization
- deepset pricing: https://www.deepset.ai/pricing
- OpenAI API pricing: https://platform.openai.com/pricing
Price note — updated December 2, 2026: Prices in this post were checked on December 2, 2026. When you are reading this, the price may be lower or higher — always check the official pricing page before you buy.
Pros
- Free Apache-2.0 framework
- Explicit pipelines make retrieval and generation inspectable
- Works with local embeddings, hosted models, local models, and many document stores
- Built-in evaluators measure retrieval and faithfulness
- Hayhooks serves pipelines as HTTP endpoints
Cons
- You must operate Python services, storage, backups, updates, and monitoring
- Retrieval depends on document preparation and chunking
- API costs scale with context and questions
- Permissions must be designed into retrieval
- A finished document-chat app is faster when custom control is not needed
Build a RAG chatbot with Haystack when you need control over documents, retrieval, prompts, sources, and deployment. Start small, prove retrieval with a test set, then move to a persistent document store. Skip it when nobody will maintain documents and infrastructure.
