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

LlamaIndex (gateway)

Was this page helpful?
Previous

AutoGen (gateway)

Next
Built with

Route LlamaIndex LLM and embedding calls through the Respan gateway to use 250+ models from different providers. Only your Respan API key is needed. No separate provider key is required when the provider is configured in Respan.

Setup

1

Install packages

$pip install respan-ai respan-instrumentation-llama-index llama-index llama-index-llms-openai llama-index-embeddings-openai
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export RESPAN_BASE_URL="https://api.respan.ai/api"
3

Point LlamaIndex to the Respan gateway

1import os
2from llama_index.core import Document, Settings, SummaryIndex
3from llama_index.embeddings.openai import OpenAIEmbedding
4from llama_index.llms.openai import OpenAI
5from respan import Respan, workflow
6from respan_instrumentation_llama_index import LlamaIndexInstrumentor
7
8respan_api_key = os.environ["RESPAN_API_KEY"]
9respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
10
11respan = Respan(
12 api_key=respan_api_key,
13 base_url=respan_base_url,
14 instrumentations=[LlamaIndexInstrumentor()],
15)
16Settings.llm = OpenAI(
17 api_key=respan_api_key,
18 api_base=respan_base_url,
19 model="gpt-4o-mini",
20)
21Settings.embed_model = OpenAIEmbedding(
22 api_key=respan_api_key,
23 api_base=respan_base_url,
24 model="text-embedding-3-small",
25)
26
27@workflow(name="gateway_rag_query")
28def run_query():
29 index = SummaryIndex.from_documents([
30 Document(text="The Respan gateway routes LlamaIndex calls to hosted models.")
31 ])
32 return index.as_query_engine().query("What does the gateway do?")
33
34print(run_query())
35respan.flush()

Switch models

Change the model parameter to use another gateway model.

1Settings.llm = OpenAI(
2 api_key=respan_api_key,
3 api_base=respan_base_url,
4 model="claude-sonnet-4-5-20250929",
5)

See Respan params & metadata for the full list.