
# Hayhooks
**Serve [Haystack](https://haystack.deepset.ai/) pipelines and agents as APIs.**
REST APIs, OpenAI-compatible chat, MCP tools, and A2A agents, with durable execution and built-in tracing.
[](https://pypi.org/project/hayhooks)
[](https://pypi.org/project/hayhooks)
[](https://github.com/deepset-ai/hayhooks/actions/workflows/docker.yml)
[](https://github.com/deepset-ai/hayhooks/actions/workflows/tests.yml)
[**Documentation**](https://deepset-ai.github.io/hayhooks/) · [Quick start](#quick-start) · [Dashboard](#terminal-dashboard) · [Durable execution](#durable-execution)
## Serve your pipelines and agents
Write a Python wrapper around your pipeline or agent. Choose the interfaces and runtime features you need:
- **REST APIs.** Deploy Python wrappers or YAML pipelines as typed, validated endpoints with OpenAPI docs, file uploads, and custom routes.
- **[OpenAI-compatible APIs](docs/features/openai-compatibility.md).** Serve streaming Chat Completions and Responses endpoints. Connect [Open WebUI](docs/features/openwebui-integration.md) or use the embedded [Chainlit UI](docs/features/chainlit-integration.md).
- **[MCP support](docs/features/mcp-support.md).** Run an MCP server that exposes pipelines and agents as tools for Cursor, Claude Desktop, and other Model Context Protocol clients.
- **[A2A support](docs/features/a2a-support.md).** Expose chat-capable pipelines and agents through the Agent2Agent protocol, with generated agent cards for discovery and task delegation.
- **[Durable execution](#durable-execution).** Checkpoint long-running work in Redis, wait for human approval, retry failures, and recover after restarts.
- **[Tracing and observability](docs/reference/tracing.md).** Inspect executions and component traces in the terminal dashboard, or export spans to an OpenTelemetry backend with `hayhooks[tracing]`.
## Terminal dashboard
Inspect deployments, follow executions, and find slow components in your terminal.
[](docs/assets/terminal-dashboard/overview-120x36.png)
*Actual terminal UI with demo data.* [Explore the dashboard](docs/features/terminal-dashboard.md).
## Quick start
Serve a Haystack agent through a typed HTTP endpoint. You need Python 3.10 through 3.14 and an OpenAI API key.
### Install and start
In your Python environment, install Hayhooks and set the API key before starting the server:
```bash
pip install hayhooks
export OPENAI_API_KEY="your-api-key"
hayhooks run
```
Leave the server running. Use a second terminal for the following commands.
### Create an agent
Create a directory named `my_agent_dir` and save this as `my_agent_dir/pipeline_wrapper.py`:
```python
from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIResponsesChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.tools import tool
from hayhooks import BasePipelineWrapper
@tool
def search(query: str) -> str:
"""Search the knowledge base."""
return f"This is a demo tool."
class PipelineWrapper(BasePipelineWrapper):
def setup(self) -> None:
self.pipeline = Agent(
chat_generator=OpenAIResponsesChatGenerator(model="gpt-4o-mini"),
tools=[search],
)
async def run_api_async(self, question: str) -> str:
result = await self.pipeline.run_async(messages=[ChatMessage.from_user(question)])
return result["last_message"].text
```
Hayhooks uses the method's type hints to validate requests and generate the API schema.
### Deploy and run
```bash
hayhooks pipeline deploy-files -n my_agent ./my_agent_dir
curl http://localhost:1416/my_agent/run \
-H 'Content-Type: application/json' \
-d '{"question": "What can you do?"}'
```
The response contains the agent's answer. Open [the API docs](http://localhost:1416/docs) to inspect and try the endpoint.