Basic example showing how to create a client and check API health.
1234
usingvarclient=newLangfuseClient(apiKey);// Check that the Langfuse API and database are healthy.varresponse=awaitclient.Health.HealthHealthAsync();
Traces
List and retrieve traces from the Langfuse API.
12345
usingvarclient=newLangfuseClient(apiKey);// List the most recent traces in your project.varresponse=awaitclient.Trace.TraceListAsync(limit:10);
Prompts
List prompts managed in Langfuse.
12345
usingvarclient=newLangfuseClient(apiKey);// List all prompts in your project.varresponse=awaitclient.Prompts.PromptsListAsync(limit:10);
Ingestion
Ingest trace events into Langfuse using the batch ingestion API.
1 2 3 4 5 6 7 8 91011121314151617181920
usingvarclient=newLangfuseClient(apiKey);// Create a trace event and send it via batch ingestion.vartraceId=Guid.NewGuid().ToString();vartraceEvent=newTraceEvent(body:newTraceBody{Id=traceId,Name="sdk-integration-test",Input="What is Langfuse?",Output="Langfuse is an open-source LLM observability platform.",});varingestionEvent=newIngestionEvent(newAllOf<IngestionEventVariant12,TraceEvent>(value1:newIngestionEventVariant12(type:IngestionEventVariant1Type.TraceCreate),value2:traceEvent));varresponse=awaitclient.Ingestion.IngestionBatchAsync(batch:[ingestionEvent]);
Projects
Get information about the project associated with the API key.
1234
usingvarclient=newLangfuseClient(apiKey);// Retrieve the project associated with your API key.varresponse=awaitclient.Projects.ProjectsGetAsync();
Scores
List scores for evaluating LLM outputs in Langfuse.
12345
usingvarclient=newLangfuseClient(apiKey);// List all scores in your project with pagination.varresponse=awaitclient.Scores.ScoresGetManyAsync(limit:10);
Datasets
List and manage datasets for LLM evaluation in Langfuse.
12345
usingvarclient=newLangfuseClient(apiKey);// List all datasets in your project with pagination.varresponse=awaitclient.Datasets.DatasetsListAsync(limit:10);