langfuse-go icon indicating copy to clipboard operation
langfuse-go copied to clipboard

feat: support New client with explicit params

Open emranbm opened this issue 7 months ago • 0 comments

Currently, the users of this library need to set the required parameters (like public/private kies) as the env variable in code. With this commit, something like this:

	err := os.Setenv("LANGFUSE_HOST", baseURL)
	if err != nil {
		return nil, fmt.Errorf("failed to set LANGFUSE_HOST: %w", err)
	}
	err = os.Setenv("LANGFUSE_PUBLIC_KEY", publicKey)
	if err != nil {
		return nil, fmt.Errorf("failed to set LANGFUSE_PUBLIC_KEY: %w", err)
	}
	err = os.Setenv("LANGFUSE_SECRET_KEY", secretKey)
	if err != nil {
		return nil, fmt.Errorf("failed to set LANGFUSE_SECRET_KEY: %w", err)
	}
	client := langfuse.New(ctx)

can be done much more simpler; like below:

	client := langfuse.NewWithEndpoint(baseURL, publicKey, secretKey)

The previous behavior is remained unchanged, for backward-compatibilty.

emranbm avatar May 13 '25 10:05 emranbm