> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate with Langfuse

### What is Langfuse

Langfuse is an open-source LLM engineering platform that helps teams collaborate on debugging, analyzing, and iterating their applications.

> [!NOTE]
>
> Introduction to Langfuse: [https://langfuse.com/](https://langfuse.com/)

### How to Configure Langfuse

1. Register and log in to Langfuse on the [official website](https://langfuse.com/)
2. Create a project in Langfuse. After logging in, click **New** on the homepage to create your own project. The **project** will be used to associate with **applications** in Dify for data monitoring.

![Create a Project in Langfuse](https://assets-docs.dify.ai/2025/04/34ca6a973c4a1230be659b313b99fd90.png)

Edit a name for the project.

![Create a Project in Langfuse](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/26cfbb94e312a100c39e217fdd0b4406.png)

3. Create project API credentials. In the left sidebar of the project, click **Settings** to open the settings.

![Create Project API Credentials](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/2ed72a6761f2977201c29e67e5bc634c.png)

In Settings, click **Create API Keys** to create project API credentials.

![Create Project API Credentials](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/3c3fbd5392d37fbccf1f9ef76c54f0bc.png)

Copy and save the **Secret Key**, **Public Key**, and **Host**.

![Get API Key Configuration](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/a2ff67951ce300082d875eae8458c8c7.png)

4. Configure Langfuse in Dify. Open the application you need to monitor, open **Monitoring** in the side menu, and select **Tracing app performance** on the page.

![Configure Langfuse](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/ebc84b328ad37c0f6dbca6101e1f90ab.png)

After clicking configure, paste the **Secret Key, Public Key, Host** created in Langfuse into the configuration and save. **Host** must be the base URL for your project's region or self-hosted instance, without `/api/public`.

> [!NOTE]
>
> Dify sends traces over OpenTelemetry, to `/api/public/otel/v1/traces`, so a self-hosted Langfuse must be v3.63.0 or later. For a new deployment, use v4.

![Configure Langfuse](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/5bfa409e7a073f133f21146535401512.png)

Once successfully saved, you can view the status on the current page.

![View Configuration Status](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/monitoring/integrate-external-ops-tools/1aa086a1aead0e29948e7d6d5815d5d1.png)

### View Monitoring Data in Langfuse

After configuration, debugging or production data of the application in Dify can be viewed in Langfuse.

![Configuration, Debugging or Production Data of the Application in Dify Can Be](https://assets-docs.dify.ai/2025/04/a2c02ccc559743b85b0f972aa513e47a.png)

![](https://assets-docs.dify.ai/2025/04/88f3adfb03f325d2ea800ba5685b9ec9.png)

> [!NOTE]
>
> After saving and enabling tracing, run the app again and check for a new trace in the monitoring service. Delivery is asynchronous; saving the configuration alone does not confirm that a trace has arrived.
>
> With both deployment switches off, the new Agent app type and workflows using the [new Agent node](https://docs.dify.ai/en/self-host/use-dify/nodes/agent.md#new-agent) still send ordinary traces, including available inputs and outputs, but omit the Agent's internal model and tool calls.
>
> To collect those calls, enable `OPS_AGENT_TRACE_ENABLED=true` on the Dify API and workers and `DIFY_AGENT_APPLICATION_TRACING_ENABLED=true` on the Agent backend. Enable them together: when an Agent call executes with only the API switch enabled and **Capture Agent internals** on (the default), trace collection times out with `agent_trace_collection_incomplete` and no trace is exported. This does not mean the app execution failed. See [Environment Variables](https://docs.dify.ai/en/self-host/deploy/configuration/environments.md#llmops-trace-delivery) for deployment settings.
>
> With API collection enabled for these apps, **Capture content** is off by default: inputs, outputs, and most metadata are removed, and error text is redacted across the whole workflow. Enable it to send that content. Classic `agent-chat` apps and workflows using only classic Agent nodes retain ordinary tracing.

### List of monitoring data

The tables below describe ordinary traces. When API collection is enabled for the new Agent app type or workflows containing a new Agent node, traces use a new UUIDv7 trace ID, with source and tracing-run IDs retained as `dify.source.id` and `dify.tracing.run_id` attributes. For the new Agent app type, `Agent attempt` spans with internal model and tool calls replace the ordinary `llm` span when **Capture Agent internals** is on. Separate moderation, suggested-question, and naming records are omitted for collected runs.

Dify exports a hierarchy of operations: a message contains an `llm` call, and a Chatflow message contains its workflow and node operations.

Trace IDs come from `X-Trace-Id` when supplied; otherwise from the message ID for Chat/Chatflow or the workflow run ID for Workflow. In Langfuse, the ID appears as 32 hexadecimal characters:

* **A UUID or 32 hexadecimal characters**, including message and workflow run IDs: the same digits, without dashes.
* **Any other `X-Trace-Id` value**: a hash of it. The original value is kept in the trace's metadata as `external_trace_id`.

Observation IDs are derived. Native token usage is reported on model calls only.

For Chatflow, the trace root is the `message`, with the user's query as input (or workflow inputs when the query is empty). Its `workflow` child retains the workflow inputs and outputs.

The detail lists below describe Dify's source records and metadata. Only the relevant, available values are exported; the raw records are not sent in full.

#### Trace the information of Workflow and Chatflow

**Tracing Workflow and Chatflow**

<table>
  <thead>
    <tr>
      <th>Workflow</th>
      <th>LangFuse Trace</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>workflow\_run\_id (Workflow) / message\_id (Chatflow), unless X-Trace-Id is supplied</td>
      <td>id (trace)</td>
    </tr>

    <tr>
      <td>user\_id</td>
      <td>userId</td>
    </tr>

    <tr>
      <td>workflow (Workflow) / message (Chatflow)</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>timestamp / startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>Workflow inputs / Chatflow query (workflow inputs if empty)</td>
      <td>input</td>
    </tr>

    <tr>
      <td>outputs</td>
      <td>output</td>
    </tr>

    <tr>
      <td>Model token consumption (LLM calls)</td>
      <td>usage</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>

    <tr>
      <td>error</td>
      <td>level (observations)</td>
    </tr>

    <tr>
      <td>error</td>
      <td>statusMessage (observations)</td>
    </tr>

    <tr>
      <td>Session ID</td>
      <td>sessionId</td>
    </tr>

    <tr>
      <td>Parent span (when present)</td>
      <td>parentObservationId (nested observations)</td>
    </tr>
  </tbody>
</table>

**Workflow Trace Info**

* workflow\_id - Unique ID of Workflow
* conversation\_id - Conversation ID
* workflow\_run\_id - Workflow ID of this runtime
* tenant\_id - Tenant ID
* elapsed\_time - Elapsed time at this runtime
* status - Runtime status
* version - Workflow version
* total\_tokens - Total token used at this runtime
* file\_list - List of files processed
* triggered\_from - Source that triggered this runtime
* workflow\_run\_inputs - Input of this workflow
* workflow\_run\_outputs - Output of this workflow
* error - Error Message
* query - Queries used at runtime
* workflow\_app\_log\_id - Workflow Application Log ID
* message\_id - Relevant Message ID
* start\_time - Start time of this runtime
* end\_time - End time of this runtime
* workflow node executions - Workflow node runtime information
* Metadata
  * workflow\_id - Unique ID of Workflow
  * conversation\_id - Conversation ID
  * workflow\_run\_id - Workflow ID of this runtime
  * tenant\_id - Tenant ID
  * elapsed\_time - Elapsed time at this runtime
  * status - Operational state
  * version - Workflow version
  * total\_tokens - Total token used at this runtime
  * file\_list - List of files processed
  * triggered\_from - Source that triggered this runtime

#### Message Trace Info

**For trace llm conversation**

<table>
  <thead>
    <tr>
      <th>Message</th>
      <th>LangFuse Generation/Trace</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>message\_id (unless X-Trace-Id is supplied)</td>
      <td>id (trace)</td>
    </tr>

    <tr>
      <td>end\_user\_session\_id (or user\_id)</td>
      <td>userId</td>
    </tr>

    <tr>
      <td>message</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>timestamp / startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>inputs</td>
      <td>input</td>
    </tr>

    <tr>
      <td>outputs</td>
      <td>output</td>
    </tr>

    <tr>
      <td>Model token consumption (LLM calls)</td>
      <td>usage</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>

    <tr>
      <td>error</td>
      <td>level (observations)</td>
    </tr>

    <tr>
      <td>error</td>
      <td>statusMessage (observations)</td>
    </tr>

    <tr>
      <td>Session ID</td>
      <td>sessionId</td>
    </tr>
  </tbody>
</table>

**Message Trace Info**

* message\_id - Message ID
* message\_data - Message data
* end\_user\_session\_id - Session ID for user
* conversation\_model - Conversation model
* message\_tokens - Message tokens
* answer\_tokens - Answer Tokens
* total\_tokens - Total Tokens from Message and Answer
* error - Error Message
* inputs - Input data
* outputs - Output data
* file\_list - List of files processed
* start\_time - Start time
* end\_time - End time
* conversation\_mode - Conversation mode
* Metadata
  * conversation\_id - Conversation ID
  * ls\_provider - Model provider
  * ls\_model\_name - Model ID
  * status - Message status
  * from\_end\_user\_id - Sending user's ID
  * from\_account\_id - Sending account's ID
  * agent\_based - Whether agent based
  * workflow\_run\_id - Workflow ID of this runtime
  * from\_source - Message source
  * message\_id - Message ID

#### Moderation Trace Information

**Used to track conversation moderation**

<table>
  <thead>
    <tr>
      <th>Moderation</th>
      <th>LangFuse Tool Observation</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>user\_id</td>
      <td>metadata.user\_id</td>
    </tr>

    <tr>
      <td>moderation</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>inputs</td>
      <td>input</td>
    </tr>

    <tr>
      <td>action, flagged</td>
      <td>output</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>

    <tr>
      <td>message\_id (unless X-Trace-Id is supplied)</td>
      <td>traceId</td>
    </tr>
  </tbody>
</table>

**Message Trace Info**

* message\_id - Message ID
* user\_id - user ID
* workflow\_app\_log\_id workflow\_app\_log\_id
* inputs - Input data for review
* message\_data - Message Data
* flagged - Whether it is flagged for attention
* action - Specific actions to implement
* preset\_response - Preset response
* start\_time - Start time of review
* end\_time - End time of review
* Metadata
  * message\_id - Message ID
  * action - Specific actions to implement
  * preset\_response - Preset response

#### Suggested Question Trace Information

**Used to track suggested questions**

<table>
  <thead>
    <tr>
      <th>Suggested Question</th>
      <th>LangFuse Tool Observation</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>user\_id</td>
      <td>metadata.user\_id</td>
    </tr>

    <tr>
      <td>suggested\_question</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>inputs</td>
      <td>input</td>
    </tr>

    <tr>
      <td>suggested\_question</td>
      <td>output</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>

    <tr>
      <td>message\_id (unless X-Trace-Id is supplied)</td>
      <td>traceId</td>
    </tr>
  </tbody>
</table>

**Message Trace Info**

* message\_id - Message ID
* message\_data - Message data
* inputs - Input data
* outputs - Output data
* start\_time - Start time
* end\_time - End time
* total\_tokens - Total tokens
* status - Message Status
* error - Error Message
* from\_account\_id - Sending account ID
* agent\_based - Whether agent based
* from\_source - Message source
* model\_provider - Model provider
* model\_id - Model ID
* suggested\_question - Suggested question
* level - Status level
* status\_message - Message status
* Metadata
  * message\_id - Message ID
  * ls\_provider - Model Provider
  * ls\_model\_name - Model ID
  * status - Message status
  * from\_end\_user\_id - Sending user's ID
  * from\_account\_id - Sending Account ID
  * workflow\_run\_id - Workflow ID of this runtime
  * from\_source - Message source

#### Dataset Retrieval Trace Information

**Used to track knowledge base retrieval**

<table>
  <thead>
    <tr>
      <th>Dataset Retrieval</th>
      <th>LangFuse Retriever Observation</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>user\_id</td>
      <td>metadata.user\_id</td>
    </tr>

    <tr>
      <td>dataset\_retrieval</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>inputs</td>
      <td>input</td>
    </tr>

    <tr>
      <td>documents</td>
      <td>output</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>

    <tr>
      <td>message\_id (unless X-Trace-Id is supplied)</td>
      <td>traceId</td>
    </tr>
  </tbody>
</table>

**Dataset Retrieval Trace Info**

* message\_id - Message ID
* inputs - Input Message
* documents - Document data
* start\_time - Start time
* end\_time - End time
* message\_data - Message data
* Metadata
  * message\_id - Message ID
  * ls\_provider - Model Provider
  * ls\_model\_name - Model ID
  * status - Model status
  * from\_end\_user\_id - Sending user's ID
  * from\_account\_id - Sending account's ID
  * agent\_based - Whether agent based
  * workflow\_run\_id - Workflow ID of this runtime
  * from\_source - Message Source

#### Tool Trace Information

**Used to track tool invocation**

<table>
  <thead>
    <tr>
      <th>Tool</th>
      <th>LangFuse Tool Observation</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>user\_id</td>
      <td>metadata.user\_id</td>
    </tr>

    <tr>
      <td>tool\_name</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>tool\_inputs</td>
      <td>input</td>
    </tr>

    <tr>
      <td>tool\_outputs</td>
      <td>output</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>

    <tr>
      <td>message\_id (unless X-Trace-Id is supplied)</td>
      <td>traceId</td>
    </tr>
  </tbody>
</table>

**Tool Trace Info**

* message\_id - Message ID
* tool\_name - Tool Name
* start\_time - Start time
* end\_time - End time
* tool\_inputs - Tool inputs
* tool\_outputs - Tool outputs
* message\_data - Message data
* error - Error Message, if exist
* inputs - Input of Message
* outputs - Output of Message
* tool\_config - Tool config
* time\_cost - Time cost
* tool\_parameters - Tool Parameters
* file\_url - URL of relevant files
* Metadata
  * message\_id - Message ID
  * tool\_name - Tool Name
  * tool\_inputs - Tool inputs
  * tool\_outputs - Tool outputs
  * tool\_config - Tool config
  * time\_cost - Time. cost
  * error - Error Message
  * tool\_parameters - Tool parameters
  * message\_file\_id - Message file ID
  * created\_by\_role - Created by role
  * created\_user\_id - Created user ID

#### Generate Name Trace

**Used to track conversation title generation**

Automatic naming without an associated message creates a standalone trace named `generate_name` with one `tool` observation. Naming linked to a message creates a `tool` observation in that message's trace. Editing a title directly does not create a naming trace.

<table>
  <thead>
    <tr>
      <th>Generate Name</th>
      <th>LangFuse Tool Observation</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>user\_id</td>
      <td>metadata.user\_id</td>
    </tr>

    <tr>
      <td>generate\_name</td>
      <td>name</td>
    </tr>

    <tr>
      <td>start\_time</td>
      <td>startTime</td>
    </tr>

    <tr>
      <td>end\_time</td>
      <td>endTime (observations)</td>
    </tr>

    <tr>
      <td>inputs</td>
      <td>input</td>
    </tr>

    <tr>
      <td>outputs</td>
      <td>output</td>
    </tr>

    <tr>
      <td>metadata</td>
      <td>metadata</td>
    </tr>
  </tbody>
</table>

**Generate Name Trace Info**

* conversation\_id - Conversation ID
* inputs - Input data
* outputs - Generated session name
* start\_time - Start time
* end\_time - End time
* tenant\_id - Tenant ID
* Metadata
  * conversation\_id - Conversation ID
  * tenant\_id - Tenant ID

### Langfuse Prompt Management

The [Langfuse Prompt Management Plugin](https://github.com/gao-ai-com/dify-plugin-langfuse) (community maintained) lets you use prompts that are [managed and versioned in Langfuse](https://langfuse.com/docs/prompt-management/get-started) in your Dify applications, enhancing your LLM application development workflow. Key features include:

* **Get Prompt**: Fetch specific prompts managed in Langfuse.
* **Search Prompts**: Search for prompts in Langfuse using various filters.
* **Update Prompt**: Create new versions of prompts in Langfuse and set tags/labels.

This integration streamlines the process of managing and versioning your prompts, contributing to more efficient development and iteration cycles. You can find the plugin and installation instructions [here](https://github.com/gao-ai-com/dify-plugin-langfuse).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.