Documentation
¶
Overview ¶
Package langfuse provides a Go client library for interacting with the Langfuse platform.
This package offers comprehensive support for observability tracing, prompt management, model configuration, datasets, sessions, scores, projects, LLM connections, comments, and annotations functionality with efficient batch processing.
Basic usage:
client := langfuse.NewClient("https://cloud.langfuse.com", "your-public-key", "your-secret-key")
defer client.Close()
trace := client.StartTrace("my-application")
span := trace.StartSpan("processing-step")
// ... your application logic
span.End()
trace.End()
Index ¶
- type LangFuse
- func (c *LangFuse) Close() error
- func (c *LangFuse) Comments() *comments.Client
- func (c *LangFuse) Datasets() *datasets.Client
- func (c *LangFuse) LLMConnections() *llmconnections.Client
- func (c *LangFuse) Models() *models.Client
- func (c *LangFuse) Organizations() *organizations.Client
- func (c *LangFuse) Projects() *projects.Client
- func (c *LangFuse) Prompts() *prompts.Client
- func (c *LangFuse) Scores() *scores.Client
- func (c *LangFuse) Sessions() *sessions.Client
- func (c *LangFuse) StartTrace(ctx context.Context, name string) *traces.Trace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LangFuse ¶
type LangFuse struct {
// contains filtered or unexported fields
}
LangFuse is the main client for interacting with the Langfuse platform.
It provides access to all Langfuse functionality including tracing, prompts, models, datasets, sessions, scores, projects, LLM connections, comments, and annotations through dedicated client instances.
The client manages HTTP connections and provides efficient batch processing for trace ingestion with automatic flushing and graceful shutdown capabilities.
func NewClient ¶
NewClient creates a new LangFuse client instance with the specified host and credentials.
The host should be the base URL of your Langfuse instance (e.g., "https://cloud.langfuse.com"). The publicKey and secretKey are obtained from your Langfuse project settings.
The client automatically configures HTTP basic authentication and sets the API base URL. Remember to call Close() when done to ensure all pending traces are flushed.
func (*LangFuse) Close ¶
Close gracefully shuts down the client and flushes all pending traces.
This method ensures that all batched traces are sent to Langfuse before the client is closed. It should be called when you're done using the client, typically in a defer statement.
Returns an error if the shutdown process fails or times out.
func (*LangFuse) Comments ¶
Comments returns a client for managing comments on traces, observations, and sessions.
Use this client to add contextual comments to your traces and observations for collaboration and debugging purposes.
func (*LangFuse) Datasets ¶
Datasets returns a client for managing datasets and dataset items.
Use this client to create and manage datasets for training, evaluation, and testing of your AI models, including dataset items and runs.
func (*LangFuse) LLMConnections ¶
func (c *LangFuse) LLMConnections() *llmconnections.Client
LLMConnections returns a client for managing LLM provider connections.
Use this client to configure connections to various LLM providers like OpenAI, Anthropic, Azure OpenAI, AWS Bedrock, and Google Vertex AI.
func (*LangFuse) Models ¶
Models returns a client for managing model configurations and pricing.
Use this client to define model pricing, match patterns, and manage model metadata for cost tracking and analytics.
func (*LangFuse) Organizations ¶
func (c *LangFuse) Organizations() *organizations.Client
Organizations returns a client for managing organization and project memberships.
Use this client to manage user roles and permissions within organizations and projects. Most operations require organization-scoped API keys.
func (*LangFuse) Projects ¶
Projects returns a client for managing projects and API keys.
Use this client to create, update, and manage projects, as well as manage API keys within projects. Most operations require organization-scoped API keys.
func (*LangFuse) Prompts ¶
Prompts returns a client for managing prompt templates and versions.
Use this client to create, retrieve, list, and manage prompt templates for your AI applications.
func (*LangFuse) Scores ¶
Scores returns a client for managing evaluation scores and score configurations.
Use this client to create, retrieve, and manage scores for your traces and observations, including score configurations for different data types.
func (*LangFuse) Sessions ¶
Sessions returns a client for managing user sessions and their associated traces.
Use this client to retrieve and analyze user sessions, including filtering by time ranges and environments.
func (*LangFuse) StartTrace ¶
StartTrace creates a new trace with the given name.
A trace represents a single execution flow in your application and can contain multiple observations (spans). Traces are automatically batched and sent to Langfuse for efficient ingestion.
Returns a Trace instance that you can use to add observations and metadata.
Directories
¶
| Path | Synopsis |
|---|---|
|
pkg
|
|
|
annotations
Package annotations provides functionality for managing annotation queues and items in Langfuse.
|
Package annotations provides functionality for managing annotation queues and items in Langfuse. |
|
batch
Package batch provides a generic, type-safe batch processor for efficient API ingestion.
|
Package batch provides a generic, type-safe batch processor for efficient API ingestion. |
|
comments
Package comments provides functionality for managing comments on traces, observations, and sessions in Langfuse.
|
Package comments provides functionality for managing comments on traces, observations, and sessions in Langfuse. |
|
common
Package common provides shared types and utilities for HTTP operations across all Langfuse clients.
|
Package common provides shared types and utilities for HTTP operations across all Langfuse clients. |
|
datasets
Package datasets provides functionality for managing datasets and dataset items in Langfuse.
|
Package datasets provides functionality for managing datasets and dataset items in Langfuse. |
|
llmconnections
Package llmconnections provides functionality for managing LLM provider connections in Langfuse.
|
Package llmconnections provides functionality for managing LLM provider connections in Langfuse. |
|
logger
Package logger provides a global zap logger instance for JSON formatted logging across the entire langfuse-go project.
|
Package logger provides a global zap logger instance for JSON formatted logging across the entire langfuse-go project. |
|
models
Package models provides functionality for managing model configurations and pricing in Langfuse.
|
Package models provides functionality for managing model configurations and pricing in Langfuse. |
|
organizations
Package organizations provides functionality for managing organization and project memberships in Langfuse.
|
Package organizations provides functionality for managing organization and project memberships in Langfuse. |
|
projects
Package projects provides functionality for managing projects and API keys in Langfuse.
|
Package projects provides functionality for managing projects and API keys in Langfuse. |
|
prompts
Package prompts provides functionality for managing prompt templates and versions in Langfuse.
|
Package prompts provides functionality for managing prompt templates and versions in Langfuse. |
|
scores
Package scores provides functionality for managing evaluation scores and score configurations in Langfuse.
|
Package scores provides functionality for managing evaluation scores and score configurations in Langfuse. |
|
sessions
Package sessions provides functionality for managing user sessions and their associated traces in Langfuse.
|
Package sessions provides functionality for managing user sessions and their associated traces in Langfuse. |
|
traces
Package traces provides functionality for distributed tracing in Langfuse.
|
Package traces provides functionality for distributed tracing in Langfuse. |