Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed. {
"mcpServers" : {
"respan-docs" : {
"url" : "https://docs.respan.ai/mcp"
}
}
}
This integration supports the Respan gateway and callback logging .
What is LiteLLM?
LiteLLM provides a unified Python interface for calling 100+ LLM providers using the OpenAI format. With Respan, you can either:
Gateway — route requests through Respan for observability, fallbacks, and load balancing
Logging — keep calling providers directly and export logs to Respan via a callback
Quickstart
Install packages
pip install litellm respan-exporter-litellm
Gateway mode
Route LiteLLM requests through the Respan gateway. This gives you full access to Respan features like fallbacks, load balancing, and prompt management.
import litellm
response = litellm.completion(
api_key = "YOUR_RESPAN_API_KEY" ,
api_base = "https://api.respan.ai/api" ,
model = "gpt-4o-mini" ,
messages = [{ "role" : "user" , "content" : "Hello!" }],
)
print (response.choices[ 0 ].message.content)
Logging mode
Register the Respan callback to log all completions automatically. Requests go directly to providers — only the logs are sent to Respan.
import litellm
from respan_exporter_litellm import RespanLiteLLMCallback
litellm.callbacks = [RespanLiteLLMCallback()]
response = litellm.completion(
model = "gpt-4o-mini" ,
messages = [{ "role" : "user" , "content" : "Hello!" }],
)
print (response.choices[ 0 ].message.content)
Supported parameters
Gateway mode (extra_body)
Pass Respan parameters using extra_body when routing through the gateway.
response = litellm.completion(
api_key = "YOUR_RESPAN_API_KEY" ,
api_base = "https://api.respan.ai/api" ,
model = "gpt-4o-mini" ,
messages = [{ "role" : "user" , "content" : "Hello!" }],
extra_body = {
"customer_identifier" : "user-123" ,
"metadata" : { "session_id" : "abc123" },
"thread_identifier" : "conversation_456" ,
},
)
Pass Respan parameters inside metadata.respan_params.
response = litellm.completion(
model = "gpt-4o-mini" ,
messages = [{ "role" : "user" , "content" : "Hello!" }],
metadata = {
"respan_params" : {
"workflow_name" : "simple_logging" ,
"span_name" : "single_log" ,
"customer_identifier" : "user-123" ,
}
},
)
Configuration
Parameter Type Default Description api_keystrRESPAN_API_KEY env varRespan API key. base_urlstr | NoneNoneAPI base URL.
See the LiteLLM Exporter SDK reference for the full API.
Async usage
The callback supports async completions automatically:
import litellm
from respan_exporter_litellm import RespanLiteLLMCallback
litellm.callbacks = [RespanLiteLLMCallback()]
response = await litellm.acompletion(
model = "gpt-4o-mini" ,
messages = [{ "role" : "user" , "content" : "Tell me a joke" }],
)
Multiple providers
LiteLLM’s unified interface means all providers are logged with the same callback:
import litellm
from respan_exporter_litellm import RespanLiteLLMCallback
litellm.callbacks = [RespanLiteLLMCallback()]
# OpenAI
litellm.completion( model = "gpt-4o-mini" , messages = [ ... ])
# Anthropic
litellm.completion( model = "claude-sonnet-4-5-20250929" , messages = [ ... ])
# Together
litellm.completion( model = "together_ai/meta-llama/Llama-3-70b" , messages = [ ... ])
Next Steps