For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DiscordPlatform
DocumentationIntegrationsAPI referenceSDKsChangelog
DocumentationIntegrationsAPI referenceSDKsChangelog
    • Overview
  • Tracing
  • Gateway
      • OpenAI Agents
      • Claude Agent SDK
      • Vercel AI SDK
      • Pydantic AI
      • CrewAI
      • Haystack
      • LangChain
      • LangGraph
      • Langflow
      • LlamaIndex
      • AutoGen
      • DSPy
      • Google ADK
      • Smolagents
      • Strands Agents
      • AgentSpec
      • Guardrails
      • Agno
      • MCP
      • BeeAI
      • Pipecat
      • Superagent
  • Others
  • Migrating
    • Braintrust
    • Portkey
    • Langfuse
LogoLogo
DiscordPlatform
On this page
  • Setup
  • Switch models
GatewayAgent Frameworks

Haystack (gateway)

Was this page helpful?
Previous

LangChain (gateway)

Next
Built with

Route Haystack’s OpenAI-compatible LLM calls through the Respan gateway to use 250+ models from different providers. No separate OpenAI provider key is required.

Setup

1

Install packages

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

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export HAYSTACK_CONTENT_TRACING_ENABLED="true"
3

Point Haystack to the Respan gateway

1import os
2
3from haystack import Pipeline
4from haystack.components.builders import PromptBuilder
5from haystack.components.generators import OpenAIGenerator
6from respan import Respan
7from respan_instrumentation_haystack import HaystackInstrumentor
8
9respan_api_key = os.environ["RESPAN_API_KEY"]
10respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai").rstrip("/")
11
12os.environ["OPENAI_API_KEY"] = respan_api_key
13os.environ["OPENAI_BASE_URL"] = f"{respan_base_url}/api/openai"
14os.environ.setdefault("HAYSTACK_CONTENT_TRACING_ENABLED", "true")
15
16respan = Respan(
17 api_key=respan_api_key,
18 base_url=respan_base_url,
19 instrumentations=[HaystackInstrumentor()],
20)
21
22pipeline = Pipeline()
23pipeline.add_component(
24 "prompt_builder",
25 PromptBuilder(template="Answer the following question: {{question}}"),
26)
27pipeline.add_component("generator", OpenAIGenerator(model="gpt-4o-mini"))
28pipeline.connect("prompt_builder", "generator")
29
30result = pipeline.run(
31 {"prompt_builder": {"question": "What is the capital of France?"}}
32)
33print(result["generator"]["replies"][0])
34
35respan.flush()

Switch models

Change the model parameter on OpenAIGenerator to use 250+ models from different providers through the same gateway.

1pipeline.add_component(
2 "generator",
3 OpenAIGenerator(model="claude-sonnet-4-5-20250929"),
4)

See the full model list.