Skip to main content
Environments let you maintain different versions of prompts and parameters across your development lifecycle. This enables you to:
  • Maintain version control: Pin stable versions to production while testing new versions in development
  • Enable staged deployments: Promote versions through dev/staging/production pipelines
  • Support A/B testing: Compare different versions across environments
  • Isolate changes: Test modifications without affecting production systems
Currently, environments work with prompts and parameters.

Create an environment

Environments are defined at the organization level:
  1. Go to Settings.
  2. Click Environments.
  3. Click + Environment.
  4. Enter a name (e.g., “production”, “staging”, “dev”).
  5. Click Create environment.

Assign to environments

To assign a specific prompt version to an environment:
  1. Go to Prompts.
  2. Open the prompt.
  3. Click the icon.
  4. Select an environment.
Once assigned, load prompts for that environment in your code:
import { loadPrompt } from "braintrust";

// Load from specific environment
const prompt = await loadPrompt({
  projectName: "My Project",
  slug: "my-prompt",
  environment: "production",
});

// Use conditional versioning
const prompt = await loadPrompt({
  projectName: "My Project",
  slug: "my-prompt",
  version: process.env.NODE_ENV === "production" ? "5878bd218351fb8e" : undefined,
});

Promote versions

Move tested versions from development to production:
  1. Test a new prompt or parameter version in the “dev” environment.
  2. Run experiments to validate performance.
  3. Once satisfied, assign the same version to “staging”.
  4. After final validation, assign to “production”.
This workflow ensures changes are validated before reaching production users.

Monitor environment changes

Set up environment alerts to get notified via webhook or Slack when prompt or parameter versions are assigned to or removed from environments. Use these to track deployments, maintain audit trails, or trigger downstream CI/CD workflows.

Common patterns

Three-tier deployment

Maintain dev, staging, and production environments:
  • dev: Latest changes, frequent updates, used by developers.
  • staging: Pre-release testing, stable versions.
  • production: Customer-facing, only validated versions.

Feature flags

Use environments to control feature rollouts:
  • Create an environment for each feature flag.
  • Assign different prompt or parameter versions based on flag state.
  • Gradually roll out by changing environment assignments.

A/B testing

Test variations by environment:
  • Create environments for each variant (e.g., “variant-a”, “variant-b”).
  • Assign different prompt or parameter versions to each.
  • Route users to different environments based on A/B test assignment.
  • Compare performance using environment filters.

Next steps