The Respan Haystack integration provides both gateway routing and workflow tracing for Haystack pipelines. Replace the default OpenAIGenerator with KeywordsAIGenerator for automatic logging, fallbacks, load balancing, and cost optimization.
The tracing integration captures the full pipeline execution timeline - individual component inputs and outputs, per-component timing metrics, and token usage. Manage prompts centrally through the Respan platform for version control and A/B testing.
Install keywordsai-exporter-haystack and set the KEYWORDSAI_API_KEY environment variable. Replace OpenAIGenerator with KeywordsAIGenerator in your pipeline.
For tracing, add the KeywordsAIConnector component to your pipeline. It captures data flow across retrievers, prompt builders, and LLMs as hierarchical traces viewable in the Respan dashboard.
python
from keywordsai_haystack import KeywordsAIGenerator
from haystack import Pipeline
pipe = Pipeline()
pipe.add_component("llm", KeywordsAIGenerator(model="gpt-4o-mini"))
result = pipe.run({
"llm": {"prompt": "Explain the RAG pattern."}
})