Open SourcePython

Haystack

by deepsetUpdated Jun 15, 2025

Production-ready framework for building composable NLP and AI pipelines. Haystack 2.x uses a component-based architecture where each component (generators, retrievers, converters, etc.) is a self-contained unit that can be connected into pipelines. While primarily a pipeline framework, it supports agentic patterns through its ChatGenerator components and tool use capabilities.

Architecture Overview

Haystack 2.x uses a directed acyclic graph (DAG) pipeline architecture where components are nodes connected by typed input/output sockets. Each component declares its inputs and outputs, and the pipeline validates connections at build time. Components are run in topological order with automatic data routing. For agentic patterns, the framework provides ChatGenerator components that support tool use, with a pipeline loop that feeds tool results back to the model until it produces a final response.

When to Use Haystack

  • Production NLP and RAG pipelines
  • Document processing and indexing at scale
  • Hybrid search (semantic + keyword) systems
  • Enterprise question answering platforms
  • Agentic pipelines with tool-using LLMs

Strengths & Weaknesses

Strengths

  • Battle-tested pipeline architecture for production use
  • Type-safe component connections with validation
  • Rich integration ecosystem (50+ components)
  • Excellent documentation and tutorials
  • Self-hostable with deepset Cloud for managed deployment

Weaknesses

  • Pipeline-centric design is less flexible than free-form agents
  • Learning curve for the component/pipeline abstraction
  • Less suited for dynamic, open-ended agent behaviors

Quick Start

python
from haystack import Pipeline
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.components.builders import ChatPromptBuilder
from haystack.dataclasses import ChatMessage

# Build a simple chat pipeline
pipeline = Pipeline()
pipeline.add_component("prompt_builder", ChatPromptBuilder())
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o"))

pipeline.connect("prompt_builder.prompt", "llm.messages")

# Define a system message and user template
messages = [
    ChatMessage.from_system("You are a helpful assistant."),
    ChatMessage.from_user("Tell me about {{topic}}"),
]

# Run the pipeline
result = pipeline.run({
    "prompt_builder": {
        "template": messages,
        "template_variables": {"topic": "AI agents"},
    }
})

print(result["llm"]["replies"][0].text)

Features at a Glance

Developerdeepset
LanguagePython
LicenseApache-2.0
GitHub Stars18k+
MCP SupportNo
Multi-AgentNo

Notable Users

AirbusdeepsetBMWIntel

Resources

Explore Related Content