Skip to main content
  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.
{
  "mcpServers": {
    "respan-docs": {
      "url": "https://respan.ai/docs/mcp"
    }
  }
}

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

from haystack import Pipeline
from haystack.components.generators import OpenAIGenerator
from respan_exporter_haystack import RespanConnector

pipeline = Pipeline()
pipeline.add_component("respan", RespanConnector(api_key="your-api-key"))
pipeline.add_component("llm", OpenAIGenerator(model="gpt-4o-mini"))
pipeline.connect("respan", "llm")

result = pipeline.run({"respan": {"prompt": "Tell me a joke about AI"}})
print(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:
result = pipeline.run({
    "respan": {
        "prompt": "Tell me a joke",
        "customer_identifier": "user-123",
        "metadata": {"team": "ml"},
    }
})
AttributeDescription
customer_identifierUser/customer identifier.
metadataCustom key-value pairs.

Prompts

Use Respan-managed prompts in Haystack pipelines:
from respan_exporter_haystack import RespanGenerator

generator = RespanGenerator(
    api_key="your-api-key",
    model="gpt-4o-mini",
    prompt_id="your-prompt-id",
    prompt_version=1,
)
Looking for gateway integration? See Gateway > Haystack.