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

What is Langfuse?

Langfuse is an open-source LLM observability platform. Use the Respan Langfuse instrumentor to redirect Langfuse traces to Respan without changing your Langfuse usage. You can keep using @observe and the Langfuse SDK as usual.
Instrument before importing Langfuse so the HTTP client is patched.

Setup

1

Install packages

pip install langfuse respan-instrumentation-langfuse
2

Set environment variables

.env
RESPAN_API_KEY=your-respan-api-key
RESPAN_BASE_URL=https://api.respan.ai/api

LANGFUSE_PUBLIC_KEY=your-langfuse-public-key
LANGFUSE_SECRET_KEY=your-langfuse-secret-key
LANGFUSE_HOST=https://cloud.langfuse.com
3

Instrument and run

import dotenv
dotenv.load_dotenv(".env", override=True)

import os
from respan_instrumentation_langfuse import LangfuseInstrumentor

# Instrument BEFORE importing Langfuse
instrumentor = LangfuseInstrumentor()
instrumentor.instrument(
    api_key=os.environ["RESPAN_API_KEY"],
    endpoint=os.environ["RESPAN_BASE_URL"] + "/v1/traces/ingest",
)

from langfuse import Langfuse, observe

langfuse = Langfuse(
    public_key="pk-lf-...",
    secret_key="sk-lf-...",
    host="https://cloud.langfuse.com",
)

@observe()
def process_query(query: str):
    return f"Response to: {query}"

result = process_query("Hello World")
print(result)

langfuse.flush()
4

View your trace

Open the Traces page in the Respan dashboard.
Langfuse basic decorator tracing in Respan

Examples

Generation tracing

Mark a function as a generation with @observe(as_type="generation").
import os
from respan_instrumentation_langfuse import LangfuseInstrumentor

instrumentor = LangfuseInstrumentor()
instrumentor.instrument(api_key=os.environ["RESPAN_API_KEY"])

from langfuse import Langfuse, observe

langfuse = Langfuse(public_key="pk-lf-...", secret_key="sk-lf-...")

@observe(as_type="generation")
def generate_response(prompt: str):
    return f"Generated: {prompt}"

result = generate_response("Write a poem")
print(result)
langfuse.flush()
Langfuse generation tracing in Respan

Nested traces

Create parent-child relationships with nested @observe functions.
import os
from respan_instrumentation_langfuse import LangfuseInstrumentor

instrumentor = LangfuseInstrumentor()
instrumentor.instrument(api_key=os.environ["RESPAN_API_KEY"])

from langfuse import Langfuse, observe

langfuse = Langfuse(public_key="pk-lf-...", secret_key="sk-lf-...")

@observe()
def subtask(name: str):
    return f"Completed: {name}"

@observe()
def main_workflow(task: str):
    result1 = subtask("step 1")
    result2 = subtask("step 2")
    return f"Workflow done: {task}"

result = main_workflow("Process request")
print(result)
langfuse.flush()
Langfuse nested traces in Respan

Observability

With this integration, Respan auto-captures:
  • Langfuse traces — every @observe-decorated function as a span
  • Generations — LLM calls marked with as_type="generation"
  • Nested spans — parent-child relationships
  • Errors — failed calls and error details
View traces on the Traces page.