Releases & Versioning
You can track the effect of changes to your LLM app on metrics in Langfuse. This allows you to:
- Run experiments (A/B tests) in production and measure the impact on costs, latencies and quality.
- Example: “What is the impact of switching to a new model?”
- Explain changes to metrics over time.
- Example: “Why did latency in this chain increase?”
Releases
A release
tracks the overall version of your application. Commonly it is set to the semantic version or git commit hash of your application.
The SDKs look for a release
in the following order:
- SDK initialization
- Environment variable
- Automatically on popular platforms
SDK initialization
The Python SDK v3 allows you to set the release when initializing the client:
from langfuse import Langfuse
# Set the release when initializing the client
langfuse = Langfuse(release="v2.1.24")
You can also update the trace’s release after creation:
from langfuse import observe, get_client
@observe()
def process_data():
# Get the client and update the current trace
langfuse = get_client()
langfuse.update_current_trace(release="v2.1.24")
# ...
# With context managers
with langfuse.start_as_current_span(name="my-operation") as span:
span.update_trace(release="v2.1.24")
Via environment variable
The SDKs will look for a LANGFUSE_RELEASE
environment variable. Use it to configure the release e.g. in your CI/CD pipeline.
LANGFUSE_RELEASE = "<release_tag>" # <- github sha or other identifier
Automatically on popular platforms
If no other release
is set, the Langfuse SDKs default to a set of known release environment variables.
Supported platforms include: Vercel, Heroku, Netlify. See the full list of support environment variables for JS/TS and Python.
Versions
The version
parameter can be added to traces
and all observation types (span
, generation
, event
). Thereby, you can track the effect of a new version
on the metrics of an object with a specific name
using Langfuse analytics.
The v3 SDK is currently in beta. Please check out the SDK v3 for more details.
When using the @observe()
decorator:
from langfuse import observe, get_client
langfuse = get_client()
@observe()
def process_data():
# Set version at trace level
langfuse.update_current_trace(version="1.0")
# Set version at observation level
langfuse.update_current_span(version="1.0")
When creating spans directly:
from langfuse import Langfuse
langfuse = Langfuse()
# Set version when creating a span
with langfuse.start_as_current_span(
name="process-data",
version="1.0"
) as span:
# Processing...
# Create a generation with version
with span.start_as_current_generation(
name="guess-countries",
model="gpt-4o",
version="1.0"
) as generation:
# Generation code...
pass
The version parameter can be included in both spans and generations, and can be set either during creation or updated later.
Version parameter in Langfuse interface