Langfuse.Client 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Langfuse.Client --version 1.1.0
                    
NuGet\Install-Package Langfuse.Client -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Langfuse.Client" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Langfuse.Client" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Langfuse.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Langfuse.Client --version 1.1.0
                    
#r "nuget: Langfuse.Client, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Langfuse.Client@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Langfuse.Client&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Langfuse.Client&version=1.1.0
                    
Install as a Cake Tool

Langfuse .NET SDK (Unofficial)

Langfuse.OpenTelemetry Langfuse.Client Build License: MIT

Unofficial .NET SDK for Langfuse - the open-source LLM engineering platform.

Packages

Package Description Install
Langfuse.OpenTelemetry Export OTEL traces to Langfuse dotnet add package Langfuse.OpenTelemetry
Langfuse.Client Prompt management with caching dotnet add package Langfuse.Client

Langfuse.OpenTelemetry

Export .NET OpenTelemetry traces to Langfuse. Works with any OTEL-instrumented library including Semantic Kernel.

Quick Start

1. Install

dotnet add package Langfuse.OpenTelemetry

2. Set environment variables

LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://cloud.langfuse.com  # EU region (default)
# LANGFUSE_BASE_URL=https://us.cloud.langfuse.com  # US region

3. Add to your app

using Langfuse.OpenTelemetry;
using Microsoft.SemanticKernel;
using OpenTelemetry;
using OpenTelemetry.Trace;

// Enable GenAI diagnostics (prompts, tokens, completions)
AppContext.SetSwitch("Microsoft.SemanticKernel.Experimental.GenAI.EnableOTelDiagnosticsSensitive", true);

// Setup OpenTelemetry with Langfuse exporter
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource("Microsoft.SemanticKernel*")
    .AddLangfuseExporter()
    .Build();

// Use Semantic Kernel as normal
var kernel = Kernel.CreateBuilder()
    .AddOpenAIChatCompletion("gpt-4o-mini", apiKey)
    .Build();

var result = await kernel.InvokePromptAsync("Hello!");

Configuration Options

// Option 1: Environment variables (recommended)
.AddLangfuseExporter()

// Option 2: Manual configuration
.AddLangfuseExporter(options =>
{
    options.PublicKey = "pk-lf-...";
    options.SecretKey = "sk-lf-...";
    options.BaseUrl = "https://cloud.langfuse.com";
})

// Option 3: From IConfiguration (appsettings.json)
.AddLangfuseExporter(configuration)

Langfuse.Client

Access Langfuse features like Prompt Management directly from .NET with built-in caching.

Quick Start

1. Install

dotnet add package Langfuse.Client

2. Set environment variables

LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://cloud.langfuse.com

3. Use prompts

using Langfuse.Client;

var client = new LangfuseClient();

// Fetch a text prompt (cached for 60s by default)
var prompt = await client.GetPromptAsync("movie-critic");

// Compile with variables
var compiled = prompt.Compile(new Dictionary<string, string>
{
    ["criticlevel"] = "expert",
    ["movie"] = "Dune 2"
});
// -> "As an expert movie critic, do you like Dune 2?"

// Fetch a chat prompt
var chatPrompt = await client.GetChatPromptAsync("movie-critic-chat");
var messages = chatPrompt.Compile(("criticlevel", "expert"), ("movie", "Dune 2"));
// -> [{ role: "system", content: "..." }, { role: "user", content: "..." }]

Features

  • Text & Chat prompts - Full support for both prompt types
  • Variable compilation - {{variable}} syntax support
  • Version/Label selection - Fetch specific versions or labels (production, staging)
  • Client-side caching - 60s TTL by default, configurable
  • Fallback prompts - Graceful degradation when API fails
  • Config access - Access prompt config (model, temperature, etc.)
// Get specific version
var v1 = await client.GetPromptAsync("my-prompt", version: 1);

// Get by label
var staging = await client.GetPromptAsync("my-prompt", label: "staging");

// With fallback
var fallback = TextPrompt.CreateFallback("default", "Fallback prompt text");
var prompt = await client.GetPromptAsync("my-prompt", fallback: fallback);

// Access config
var model = prompt.GetConfigValue<string>("model");
var temperature = prompt.GetConfigValue<double>("temperature", 0.7);

Documentation

Running the Sample

# Set environment variables
export OPENAI_API_KEY="sk-..."
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"

# Run sample
cd samples/SemanticKernel.Sample
dotnet run

Check your Langfuse dashboard to see the traces.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.1 123 1/19/2026
1.4.0 104 1/11/2026
1.3.0 110 1/9/2026
1.2.0 451 12/11/2025
1.1.0 210 11/26/2025