ScriptsApr 6, 2026·2 min read

Haystack — Open-Source RAG & Agent Framework

Production-ready Python framework for building RAG pipelines, search systems, and AI agents with composable components. By deepset. Supports 30+ integrations. 20,000+ GitHub stars.

SC
Script Depot · 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.

pip install haystack-ai
from haystack import Pipeline
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders import PromptBuilder

pipeline = Pipeline()
pipeline.add_component("prompt", PromptBuilder(template="Answer: {{query}}"))
pipeline.add_component("llm", OpenAIGenerator(model="gpt-4o"))
pipeline.connect("prompt", "llm")

result = pipeline.run({"prompt": {"query": "What is RAG?"}})
print(result["llm"]["replies"][0])

Intro

Haystack is a production-ready Python framework by deepset for building RAG pipelines, search systems, and AI agents with 20,000+ GitHub stars. Its composable pipeline architecture lets you connect retrievers, generators, rankers, and custom components like building blocks. Supports 30+ integrations including OpenAI, Anthropic, Pinecone, Weaviate, Elasticsearch, and more. Best for teams building production search and retrieval systems that need flexibility beyond simple API wrappers. Works with: Claude, GPT-4, Gemini, Cohere, local models via Ollama. Setup time: under 2 minutes.


Core Concepts

Composable Pipelines

Build RAG, search, and agent pipelines by connecting components:

from haystack import Pipeline
from haystack.components.retrievers import InMemoryBM25Retriever
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders import PromptBuilder
from haystack.document_stores.in_memory import InMemoryDocumentStore

# Create a RAG pipeline
store = InMemoryDocumentStore()
pipeline = Pipeline()
pipeline.add_component("retriever", InMemoryBM25Retriever(document_store=store))
pipeline.add_component("prompt", PromptBuilder(
    template="Context: {{documents}}\n\nQuestion: {{query}}\nAnswer:"
))
pipeline.add_component("llm", OpenAIGenerator())
pipeline.connect("retriever", "prompt.documents")
pipeline.connect("prompt", "llm")

Document Processing

Ingest and process documents from any source:

from haystack.components.converters import PyPDFToDocument
from haystack.components.preprocessors import DocumentCleaner, DocumentSplitter

converter = PyPDFToDocument()
cleaner = DocumentCleaner()
splitter = DocumentSplitter(split_by="sentence", split_length=3)

Multiple Retrieval Strategies

  • BM25 (keyword search)
  • Dense retrieval (semantic search)
  • Hybrid (keyword + semantic)
  • Sparse retrieval

30+ Integrations

Category Integrations
LLMs OpenAI, Anthropic, Cohere, Ollama
Vector DBs Pinecone, Weaviate, Qdrant, Chroma
Search Elasticsearch, OpenSearch
Storage S3, Azure Blob, Google Cloud
Evaluation RAGAS, DeepEval

Agent Capabilities

from haystack.components.agents import Agent

agent = Agent(
    generator=OpenAIGenerator(),
    tools=[search_tool, calculator_tool, web_tool]
)
result = agent.run("Research the latest AI trends and summarize")

Key Stats

  • 20,000+ GitHub stars
  • 30+ integrations
  • 500+ contributors
  • Production-ready since 2019
  • Used by Fortune 500 companies

FAQ

Q: What is Haystack? A: Haystack is an open-source Python framework by deepset for building production RAG pipelines, search systems, and AI agents with composable, pluggable components.

Q: Is Haystack free? A: Yes, fully open-source under Apache 2.0 license. deepset offers managed cloud hosting.

Q: How is Haystack different from LangChain? A: Haystack focuses on production-grade pipelines with strong typing and component validation. LangChain is more flexible but less opinionated. Haystack excels at search and retrieval use cases.


🙏

Source & Thanks

Created by deepset. Licensed under Apache 2.0.

haystack — ⭐ 20,000+

Thanks to the deepset team for making production RAG accessible to every developer.

Discussion

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

Related Assets