LangFuse

Comprehensive AI observability and analytics for Drupal applications.

Built on the Dropsolid LangFuse PHP SDK (GitLab repo), this module integrates with LangFuse to provide detailed tracing, analytics, and insights for all your AI interactions in Drupal.

Image removed.

Key Features

  • Zero-configuration AI tracking: Automatically captures AI.module interactions.
  • Unified request tracing: Group multiple AI operations (e.g., embeddings + chat) into a single trace.
  • Comprehensive analytics: Token usage, response times, and model performance metrics.
  • Multiple authentication methods: API key pair (recommended), bearer token, basic auth, and self-hosted support.
  • Production-ready: Error handling, caching, and performance optimizations.
  • Developer-friendly: Rich debugging information and an extensible architecture.

Quick Start

Requirements

Installation

composer require drupal/langfuse

# Enable the core module
drush en langfuse -y

# Optional: AI.module integration (recommended)
drush en langfuse_ai_logging -y

# Optional: Example demonstrations
drush en langfuse_example -y

Configuration

Image removed.

  1. Go to /admin/config/system/langfuse/settings.
  2. Enter your LangFuse URL, e.g. https://cloud.langfuse.com or your self-hosted URL.
  3. Select an authentication method: API key pair (recommended), bearer token, or basic auth.
  4. Enter credentials from your LangFuse project settings.
  5. Save configuration. The connection is tested automatically.

How It Works

With the langfuse_ai_logging submodule enabled, AI.module interactions are logged automatically—no code changes required.

  • Programmatic calls via AI.module services.
  • AI Explorer at /admin/config/ai/explorer.
  • Any AI.module integration: chat forms, embeddings, moderation, and more.
// This request will be automatically tracked in LangFuse.
$ai_provider = \Drupal::service('ai.provider');
$response = $ai_provider->generateText('Explain quantum computing');

Module Architecture

Core Module (langfuse)

  • LangFuse Client Service (langfuse.client): Main interface to the LangFuse SDK.
  • Configuration management: Secure credential storage supporting multiple auth methods.
  • Connection testing: Automatic validation of LangFuse connectivity.

AI.module Integration (langfuse_ai_logging)

  • Event-driven architecture: Subscribes to AI.module pre/post generation events.
  • Unified request tracing: Creates single traces containing multiple AI operations.
  • Zero developer effort: Works automatically with any AI.module integration.

Example Implementation (langfuse_example)

  • OpenAI demo form: Interactive example with chat completions.
  • Manual trace management: Demonstrates creating custom traces outside AI.module.

Resources

Short name
langfuse
Supporting organizations