Haystack
Open-source AI orchestration framework by deepset for building production-ready LLM applications in Python. Core abstraction is the Pipeline — a computation graph of Components (embedders, retrievers, generators, rankers, etc.) connected via explicit typed edges. Supports RAG, agents, semantic search, and multimodal workflows. Integrates with OpenAI, Anthropic, Mistral, Hugging Face, Azure, Bedrock, and 70+ vector databases and document stores.
Warnings
- breaking Haystack 1.x (farm-haystack) reached End of Life on March 11, 2025. Final version is 1.26.4. No further updates or security patches. The correct package for Haystack 2.x is haystack-ai, NOT farm-haystack.
- breaking farm-haystack and haystack-ai CANNOT coexist in the same Python environment. Installing both causes import conflicts and unpredictable failures — haystack namespace is shared but incompatible between the two packages.
- breaking All 1.x Nodes are gone in 2.x. Pipeline.add_node() does not exist. The entire node API (BaseComponent subclasses, PromptNode, FARMReader, EmbeddingRetriever, etc.) has been replaced with Components using the @component decorator and Pipeline.add_component() + Pipeline.connect().
- breaking DocumentStore is no longer a pipeline component/node in 2.x. In 1.x, a DocumentStore could be the terminal node of an indexing pipeline. In 2.x, DocumentStores are plain Python objects passed to Retriever components. Use DocumentWriter component to write to a store at the end of a pipeline.
- breaking Pipeline connections must be explicit in 2.x. In 1.x, nodes were chained implicitly in order. In 2.x, you must call pipeline.connect('component_a.output_name', 'component_b.input_name') for every edge — both the component name AND the socket name are required.
- breaking Python 3.9 support dropped as of Haystack 2.22+ (October 2025). Python 3.9 reached EOL and Haystack now requires >=3.10.
- gotcha pip install haystack installs an unrelated package (not Haystack by deepset). The correct package name is haystack-ai.
- gotcha Optional dependencies (pypdf, sentence-transformers, transformers, etc.) are NOT included in the base install. Components that need them will raise an ImportError at runtime with the specific pip install command needed. This is by design for a lightweight install.
- gotcha RegexTextExtractor.return_empty_on_no_match parameter removed in 2.23.0. Previously ignored since 2.22, now raises an error on initialization if passed.
- gotcha Haystack collects anonymous telemetry by default (pipeline component usage). To opt out, set the HAYSTACK_TELEMETRY_ENABLED=false environment variable.
Install
-
pip install haystack-ai -
pip install haystack-ai[all]
Imports
- Pipeline
from haystack import Pipeline
- component decorator
from haystack import component
- OpenAIChatGenerator
from haystack.components.generators.chat import OpenAIChatGenerator
- InMemoryDocumentStore
from haystack.document_stores.in_memory import InMemoryDocumentStore
Quickstart
import os
from haystack import Pipeline
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
from haystack.components.builders import PromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
os.environ["OPENAI_API_KEY"] = "sk-..."
document_store = InMemoryDocumentStore()
# Index docs separately: document_store.write_documents([...])
template = """
Given the following context, answer the question.
Context: {% for doc in documents %}{{ doc.content }}{% endfor %}
Question: {{ question }}
"""
pipeline = Pipeline()
pipeline.add_component("retriever", InMemoryBM25Retriever(document_store=document_store))
pipeline.add_component("prompt", PromptBuilder(template=template))
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o"))
pipeline.connect("retriever.documents", "prompt.documents")
pipeline.connect("prompt.prompt", "llm.messages")
result = pipeline.run({"retriever": {"query": "What is Haystack?"}, "prompt": {"question": "What is Haystack?"}})
print(result["llm"]["replies"][0].text)