Integration Llamaindex Workflows
Observability for LlamaIndex Workflows
This cookbook demonstrates how to use Langfuse to gain real-time observability for your LlamaIndex Workflows.
What are LlamaIndex Workflows? LlamaIndex Workflows is a flexible, event-driven framework designed to build robust AI agents. In LlamaIndex, workflows are created by chaining together multiple steps—each defined and validated using the
@stepdecorator. Every step processes specific event types, allowing you to orchestrate complex processes such as AI agent collaboration, RAG flows, data extraction, and more.
What is Langfuse? Langfuse is the open source LLM engineering platform. It helps teams to collaboratively manage prompts, trace applications, debug problems, and evaluate their LLM system in production.
Get Started
We'll walk through a simple example of using LlamaIndex Workflows and integrating it with Langfuse.
Step 1: Install Dependencies
Step 2: Set Up Environment Variables
Configure your Langfuse API keys. You can get them by signing up for Langfuse Cloud or self-hosting Langfuse.
With the environment variables set, we can now initialize the Langfuse client. get_client() initializes the Langfuse client using the credentials provided in the environment variables.
Step 3: Initialize LlamaIndex Instrumentation
Now, we initialize the OpenInference LlamaIndex instrumentation. This third-party instrumentation automatically captures LlamaIndex operations and exports OpenTelemetry (OTel) spans to Langfuse.
Step 4: Create a Simple LlamaIndex Workflows Application
In LlamaIndex Workflows, you build event-driven AI agents by defining steps with the @step decorator. Each step processes an event and, if appropriate, emits new events. In this example, we create a simple workflow with two steps: one that pre-processes an incoming event and another that generates a reply.
Step 5: View Traces in Langfuse
After running your workflow, log in to Langfuse to explore the generated traces. You will see logs for each workflow step along with metrics such as token counts, latencies, and execution paths.

Public example trace in Langfuse
Note: To add additional trace attributes like tags or metadata or use LlamaIndex Workflows together with other Langfuse features please refer to this guide.