Haystack

Trace Haystack pipelines with Respan.
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page

Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://mcp.respan.ai/mcp/docs"
5 }
6 }
7}

What is Haystack?

Haystack is a Python framework for building production-ready LLM pipelines. It provides components for retrieval, generation, and processing that can be composed into pipelines.

Setup

1

Install packages

$pip install respan-exporter-haystack haystack-ai
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
3

Add RespanConnector to your pipeline

1from haystack import Pipeline
2from haystack.components.generators import OpenAIGenerator
3from respan_exporter_haystack import RespanConnector
4
5pipeline = Pipeline()
6pipeline.add_component("respan", RespanConnector(api_key="your-api-key"))
7pipeline.add_component("llm", OpenAIGenerator(model="gpt-4o-mini"))
8pipeline.connect("respan", "llm")
9
10result = pipeline.run({"respan": {"prompt": "Tell me a joke about AI"}})
11print(result)
4

View your trace

Open the Traces page to see your pipeline trace.

Haystack pipeline trace

Configuration

See the Haystack Exporter SDK reference for the full API.

ComponentDescription
RespanConnectorConnects pipelines to Respan for tracing.
RespanTracerAlternative tracing integration.
RespanGeneratorRoutes LLM calls through the Respan gateway.
RespanChatGeneratorChat-specific gateway component.

Attributes

Pass Respan attributes through the connector:

1result = pipeline.run({
2 "respan": {
3 "prompt": "Tell me a joke",
4 "customer_identifier": "user-123",
5 "metadata": {"team": "ml"},
6 }
7})
AttributeDescription
customer_identifierUser/customer identifier.
metadataCustom key-value pairs.

Prompts

Use Respan-managed prompts in Haystack pipelines:

1from respan_exporter_haystack import RespanGenerator
2
3generator = RespanGenerator(
4 api_key="your-api-key",
5 model="gpt-4o-mini",
6 prompt_id="your-prompt-id",
7 prompt_version=1,
8)

Looking for gateway integration? See Gateway > Haystack.