Prompt Version Control
In Langfuse, version control & deployment of prompts is managed via versions
and labels
.
Versions & Labels
Each prompt version is automatically assigned a version ID
. Additionally, you can assign labels
to follow your own versioning scheme.
Labels can be used to assign prompts to environments (staging, production), tenants (tenant-1, tenant-2), or experiments (prod-a, prod-b).
Use the Langfuse UI to assign labels to a prompt.
Fetching by Label or Version
When fetching prompts to use them in your application you can either do you by fetching a specific version or label. Here are code examples for fetching prompts by label or version.
To “deploy” a prompt version, you have to assign the label production
or any environment label you created to that prompt version.
Some notes on fetching prompts:
- The
latest
label points to the most recently created version. - When using a prompt without specifying a label, Langfuse will serve the version with the
production
label.
from langfuse import get_client
# Initialize Langfuse client
langfuse = get_client()
# Get specific version
prompt = langfuse.get_prompt("movie-critic", version=1)
# Get specific label
prompt = langfuse.get_prompt("movie-critic", label="staging")
# Get latest prompt version. The 'latest' label is automatically maintained by Langfuse.
prompt = langfuse.get_prompt("movie-critic", label="latest")
Rollbacks
When a prompt has a production
label, then that version will be served by default in the SDKs. You can quickly rollback to a previous version by setting the production
label to that previous version in the Langfuse UI.
Prompt Diffs
The prompt version diff view shows you the changes you made to the prompt over time. This helps you understand how the prompt has evolved and what changes have been made to debug issues or understand the impact of changes.
Protected prompt labels
- Hobby(Not Available)
- Core(Not Available)
- Pro(Team Add-On)(Team)
- Enterprise
- Self Hosted(Enterprise Edition)(Enterprise)
Protected prompt labels give project admins and owners (RBAC docs) the ability to prevent labels from being modified or deleted, ensuring better control over prompt deployment.
Once a label such as production
is marked as protected:
viewer
andmember
roles cannot modify or delete the label from prompts, preventing changes to theproduction
prompt version. This also blocks the deletion of the prompt.admin
andowner
roles can still modify or delete the label, effectively changing theproduction
prompt version.
Admins and owners can update a label’s protection status in the project settings.