Use Prompts in Your Application
Once a prompt looks good in the editor, the production workflow is:
- Save a version on the Prompts page.
- Promote the version by moving a label such as
production. - Fetch that labeled prompt from your application.
- Render the template with runtime variables before sending it to your model.
Saving a version and promoting a version are separate steps.
- Save the version you want on the Prompts page.
- Move the serving label on the Managed Variables page for that prompt.
This lets you iterate on drafts without changing what production imports.
Today, application code fetches prompts with logfire.var(...).
import logfire
prompt_var = logfire.var(name='prompt__welcome_email', default='')
with prompt_var.get(label='production') as resolved:
template = resolved.value
The name currently follows the pattern prompt__<slug_with_underscores>.
If your prompt slug is welcome-email, the SDK name is prompt__welcome_email.
The SDK returns the template string. Your application renders it with runtime variables before passing the result to your model client.
If you keep your templates to flat variables such as {{customer_name}}, simple substitution is often enough.
If you want to use dotted paths or Handlebars block helpers, use a renderer that supports the same Handlebars features documented in Template Reference.
import logfire
customer_name = 'Taylor'
prompt_var = logfire.var(name='prompt__welcome_email', default='')
with prompt_var.get(label='production') as resolved:
rendered_prompt = resolved.value.replace('{{customer_name}}', customer_name)
Here is a slightly more complete example:
import logfire
customer_name = 'Taylor'
def render_prompt(template: str, variables: dict[str, str]) -> str:
rendered = template
for key, value in variables.items():
rendered = rendered.replace(f'{{{{{key}}}}}', value)
return rendered
prompt_var = logfire.var(name='prompt__welcome_email', default='')
with prompt_var.get(label='production') as resolved:
prompt = render_prompt(resolved.value, {'customer_name': customer_name})
# Pass `prompt` to your model client here.