Applies to:
Use case
In order to use Braintrust as a central prompt registry for production agentic workflows, enabling developers to save prompts in Braintrust and automatically make them available in external systems, with environment-based deployment controls and update notifications.Features used
Prompts API: The REST API endpoints (/v1/prompt) allow you to programmatically query, list, and retrieve prompt objects with filtering by project, slug, version, and other parameters.
SDK loadPrompt(): The Braintrust SDK provides a loadPrompt() function that enables loading prompts directly in production code with support for version pinning and environment tags, eliminating the need for manual API calls.
Environment Tags: Tags (production, staging, development) allow you to associate prompt versions with specific environments and promote prompts through your deployment pipeline in a controlled manner.
Environment Update Alerts: Webhook-based alerts that trigger when environment tags are added or removed from prompts, providing a user-initiated workflow for syncing prompt updates to external systems.
Steps
Step 1: Query prompts using the API
Use the Prompts API to list or retrieve specific prompt objects. The API supports filtering by project, slug, version, and other parameters. List prompts:Step 2: Load prompts directly in production code using the SDK
For production workflows, use the SDK’sloadPrompt() function to load prompts directly in your code. This approach supports version pinning and environment tags, allowing you to control which prompt version is used in different environments.
version parameter to always load the latest version tagged with the specified environment.
Step 3: Configure environment tags for prompt deployment
Environment tags allow you to promote prompt versions through your deployment pipeline (e.g., development → staging → production). To add an environment tag to a prompt:- Navigate to your prompt in the Braintrust UI
- Click the dropdown button in the top right of the prompt view
- Select or create an environment tag (production, staging, development, etc.)
- The tag is now associated with the current prompt version
/v1/prompt endpoint with the environment filter.
Step 4: Set up environment update alerts for webhook notifications
While Braintrust doesn’t currently provide a webhook that fires on every prompt change, you can set up environment update alerts to receive notifications when prompts are promoted to specific environments. This provides a controlled, user-initiated workflow for syncing prompt updates. To configure an environment update alert:- Click Settings on the left-hand navigation bar of your project
- Click Alerts on the left-hand side of the Settings page
- Click the + Alert button in the top right
- Enter an Alert name (e.g., “Production Prompt Update”)
- Select “Environment update” as the Event Type
- Select either “All environments” or specify the specific environment tag (e.g., “production”)
- Select “Webhook URL” as the Action type
- Enter your webhook endpoint URL
- Click Create alert
Step 5: Handle webhook payloads and sync prompts
When your webhook endpoint receives an environment update notification, call the/v1/prompt API endpoint to fetch the latest prompt version and update your external system.