Skip to main content
LangWatch enables A/B testing by allowing you to create different versions of your prompts and randomly alternate between them. Your application can test different prompt variants while LangWatch tracks performance metrics for each version.

How It Works

  1. Create variants as different versions of the same prompt
  2. Switch between versions at runtime with an A/B testing strategy
  3. Track performance using LangWatch’s built-in analytics
  4. Compare results to see which version performs better

Implementation

Create Prompt Variants

Create different versions of your prompt for testing:

Run A/B Tests

Use the captured version numbers to switch between prompt versions at runtime (random sampling):

Track Performance

LangWatch automatically tracks performance metrics for each prompt version:
  • Response latency - Which version is faster?
  • Token usage - Which version is more efficient?
  • Cost per request - Which version is more cost-effective?
  • Quality scores - Which version produces better responses?

Analyze Results

Compare metrics between versions in the LangWatch UI to see which variant performs better. Use this data to make informed decisions about which prompt version to use in production.