Skip to main content
MLflow is a versatile, open-source platform for managing workflows and artifacts across the machine learning and generative AI lifecycle. It has built-in integrations with many popular AI and ML libraries, but can be used with any library, algorithm, or deployment tool.
MLflow’s LangChain integration provides the following capabilities:
  • Tracing: Visualize data flows through your LangChain components with one line of code (mlflow.langchain.autolog())
  • Experiment Tracking: Log artifacts, code, and metrics from your LangChain runs
  • Model Management: Version and deploy LangChain applications with dependency tracking
  • Evaluation: Measure the performance of your LangChain applications
Note: MLflow tracing is available in MLflow versions 2.14.0 and later. This short guide focuses on MLflow’s tracing capability for LangChain and LangGraph applications. You’ll see how to enable tracing with one line of code and view the execution flow of your applications. For information about MLflow’s other capabilities and to explore additional tutorials, please refer to the MLflow documentation for LangChain. If you’re new to MLflow, check out the Getting Started with MLflow guide.

Setup

To get started with MLflow tracing for LangChain, install the MLflow Python package. We will also use the langchain-openai package.
Next, set the MLflow tracking URI and OpenAI API key.

MLflow tracing

MLflow’s tracing capability helps you visualize the execution flow of your LangChain applications. Here’s how to enable it.

Example: Tracing a LangChain Application

Here’s a complete example showing MLflow tracing with LangChain:
To view the trace, run mlflow ui in your terminal and navigate to the Traces tab in the MLflow UI.

Example: Tracing a LangGraph Application

MLflow also supports tracing LangGraph applications:
To view the trace, run mlflow ui in your terminal and navigate to the Traces tab in the MLflow UI.

Resources

For more information on using MLflow with LangChain, please visit: