Skip to main content
Quick setup? Copy the scenarios prompt into your coding agent to add simulation tests automatically.
This guide will walk you through the basic setup required to run your first simulation and see the results in LangWatch. For more in-depth information and advanced use cases, please refer to the official scenario library documentation.

1. Installation

First, you need to install the scenario library in your project. Choose your language below.

2. Configure Environment Variables

We recommend creating a .env file in the root of your project to manage your environment variables.
.env
You can find your LANGWATCH_API_KEY in your LangWatch project settings.

3. Create a Basic Scenario

Here’s how to create and run a simple scenario to test an agent. First, you need to create an agent adapter that implements your agent logic. For detailed information about agent integration patterns, see the agent integration guide.
Once you run this code, you will see a new scenario run appear in the Simulations section of your LangWatch project.

4. Grouping Your Sets and Batches

While optional, we strongly recommend setting stable identifiers for your scenarios, sets, and batches for better organization and tracking in LangWatch.
  • id: A unique and stable identifier for your scenario. If not provided, it’s often generated from the name, which can be brittle if you rename the test.
  • setId: Groups related scenarios into a test suite. This corresponds to the “Simulation Set” in the UI.
  • batchId: Groups all scenarios that were run together in a single execution (e.g., a single CI job). You can use a CI environment variable like process.env.GITHUB_RUN_ID for this.