Skip to content

Hayhooks

Easily deploy Haystack pipelines as REST APIs and MCP Tools.

Install

$pip install hayhooks

Install command taken from the project's README or registry entry. Always review code before running it.

Hayhooks

Serve Haystack Pipelines and Agents as production APIs:REST, OpenAI-compatible chat, MCP, A2A, and durable executions that survive restarts.

Documentation · Quick start · Durable execution · Examples


Write a small Python wrapper around your Pipeline or Agent, and Hayhooks turns it into typed endpoints, streaming chat backends, and agent-to-agent tools. When the work outlives a request, a restart, or a deploy, run it as a durable execution: checkpointed in Redis, resumable on any replica, and able to wait for a human.

📦 REST APIs from Python Every wrapper or YAML pipeline becomes typed, validated endpoints with OpenAPI docs, file uploads, and custom routes.

♻️ Durable executions Checkpoints, retries, human approval, cancellation, and restart recovery for long-running Pipelines and Agents. Learn more

💬 OpenAI-compatible chat Streaming /chat/completions and /responses backends for Open WebUI, or an embedded Chainlit UI with --with-chainlit.

🛠️ MCP server Each pipeline becomes an MCP tool in Cursor, Claude Desktop, or any MCP client, which can also deploy and run pipelines through chat.

🤝 A2A protocol Publish pipelines as A2A agents (guide) with auto-generated agent cards, so other agents can delegate tasks to them.

📈 Tracing and dashboard OpenTelemetry spans (hayhooks[tracing]) for deploy, run, and durable attempts, with trace/span inspection in hayhooks dashboard --traces. Authenticated local monitoring is enabled by default.

Quick start

1. Install Hayhooks

# Install Hayhooks
pip install hayhooks

2. Start Hayhooks

hayhooks run

3. Create a simple agent

Create a minimal agent wrapper with streaming chat support and a simple HTTP POST API:

from typing import AsyncGenerator
from haystack.components.agents import Agent
from haystack.dataclasses import ChatMessage
from haystack.tools import Tool
from haystack.components.generators.chat import OpenAIChatGenerator
from hayhooks import BasePipelineWrapper, async_streaming_generator

# Define a Haystack Tool that provides weather information for a given location.
def weather_function(location):
    return f"The weather in {location} is sunny."

weather_tool = Tool(
    name="weather_tool",
    description="Provides weather information for a given location.",
    parameters={
        "type": "object",
        "properties": {"location": {"type": "string"}},
        "required": ["location"],
    },
    function=weather_function,
)

class PipelineWrapper(BasePipelineWrapper):
    def setup(self) -> None:
        self.agent = Agent(
            chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
            system_prompt="You're a helpful agent",
            tools=[weather_tool],
        )

Similar plugs

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype…

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io