Updated and supported automatically if there are no breaking changes
All modern .NET features - nullability, trimming, NativeAOT, etc.
Targets .NET 10
Langfuse v4 migration
This SDK uses the current v4 public APIs. See MIGRATION.md for
breaking changes, replacement methods, and self-hosted compatibility. Langfuse
Cloud removes legacy reads and trace ingestion on November 16, 2026.
Basic example showing how to create a client and check API health.
1234
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Check that the Langfuse API and database are healthy.varresponse=awaitclient.Health.HealthHealthAsync();
Observations
List observations from the current Langfuse API.
12345678
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Bound observation reads to a time range; follow response.Meta.Cursor for more rows.varend=DateTime.UtcNow;varresponse=awaitclient.Observations.ObservationsGetManyAsync(limit:10,fromStartTime:end.AddDays(-1),toStartTime:end);
Prompts
List prompts managed in Langfuse.
12345
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// List all prompts in your project.varresponse=awaitclient.Prompts.PromptsListAsync(limit:10);
OpenTelemetry ingestion
Ingest trace spans into Langfuse using the current OpenTelemetry endpoint.
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Use the v4 ingestion header for real-time observation visibility.varoptions=newAutoSDKRequestOptions{Headers={["x-langfuse-ingestion-version"]="4"},};// Create a span and send it via OTLP/HTTP JSON ingestion.varnowNanoseconds=(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()*1_000_000).ToString();varresponse=awaitclient.Opentelemetry.OpentelemetryExportTracesAsync(resourceSpans:[ new OtelResourceSpan { ScopeSpans = [ new OtelScopeSpan { Spans = [ new OtelSpan { TraceId = Guid.NewGuid().ToString("N"), SpanId = Guid.NewGuid().ToString("N")[..16],Name="sdk-integration-test",Kind=1,StartTimeUnixNano=nowNanoseconds,EndTimeUnixNano=nowNanoseconds,},],},],},],requestOptions:options);
Projects
Get information about the project associated with the API key.
1234
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Retrieve the project associated with your API key.varresponse=awaitclient.Projects.ProjectsGetAsync();
Scores
List scores for evaluating LLM outputs in Langfuse.
12345
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Read Scores API v3. Use cursor pagination instead of the legacy page parameter.varresponse=awaitclient.Scores.ScoresGetManyAsync(limit:10);
Datasets
List and manage datasets for LLM evaluation in Langfuse.
12345
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// List all datasets in your project with pagination.varresponse=awaitclient.Datasets.DatasetsListAsync(limit:10);
Experiments
Read experiment runs and items instead of deprecated dataset-run endpoints.
12345678
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Experiment queries require a start time and use cursor pagination.varend=DateTime.UtcNow;varresponse=awaitclient.Experiments.ExperimentsListAsync(fromStartTime:end.AddDays(-1),toStartTime:end,limit:10);
Experiment Items
Read experiment items instead of deprecated dataset-run items.
12345678
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Use experimentId or experimentName to select a run; follow Meta.Cursor.varend=DateTime.UtcNow;varresponse=awaitclient.Experiments.ExperimentsListItemsAsync(fromStartTime:end.AddDays(-1),toStartTime:end,limit:10);
Metrics
Query aggregate observation metrics through Metrics API v2.
123456789
usingvarclient=newLangfuseClient(username:publicKey,password:secretKey);// Query observations in a bounded UTC interval instead of legacy trace metrics.varend=DateTime.UtcNow;varquery=$$"""{"view":"observations","metrics":[{"measure":"count","aggregation":"count"}],"dimensions":[],"filters":[],"fromTimestamp":"{{end.AddDays(-1):O}}","toTimestamp":"{{end:O}}"}""";varresponse=awaitclient.Metrics.MetricsMetricsAsync(query:query);
Ecosystem maintenance
This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.