BrowserStack AI Evals

Experiment Workflow

Run a full evaluation from the terminal — discover providers, build a dataset and evaluators, create a prompt and experiment, then read the scores.

Experiment Workflow

Provider discovery

Always run provider discovery before creating prompts or LLM evaluators:

aievals provider list --format json

Use the exact name field (case-sensitive) for --model-params-provider. The name and adapter fields can differ (e.g., name="OpenAI" vs. adapter="openai").

Using the wrong provider value causes silent 0 scores on LLM evaluators. Always copy values from provider list — never guess, hardcode, or lowercase them.

The workflow

Discover providers

aievals provider list --format json

Discover available providers and models, and the exact values to use below.

Create a dataset

aievals dataset create
# then add items with:
aievals dataset-item create

Create evaluator(s)

aievals evaluator create

Code evaluators must use function main(...), not function evaluate(...). All params (input, output, expected) are strings — use JSON.parse() to access fields.

Create a metric

aievals metrics create

Groups evaluators (called "Metrics" in the UI, evaluator-list in the API).

Create a prompt

aievals prompt create \
  --model-params '{"provider":"OpenAI","adapter":"openai","model":"gpt-4o-mini"}'

Use exact values from Step 1.

Create the experiment

aievals experiment create

Links dataset + prompt + metrics.

Run it

aievals experiment-run create --experiment-id <id> --wait

Runs and waits for results.

Read the scores

aievals experiment-run compare <run-id> --format json

Returns aggregate scores per evaluator. For individual scores:

# get score IDs from each trace's `scores` array
aievals trace list --format json
# then fetch a single score
aievals score get <score-id> --format json

Running experiments locally

Use experiment-run run when you have .experiment.ts or .experiment.py files that call the SDK's two-step API. The CLI discovers files, injects credentials, spawns the runner, and streams progress. Results are pushed to the platform automatically.

Use experiment-run run for local SDK files. experiment-run create is for triggering server-side runs on existing experiments — do not mix them.

Prerequisites

  1. Authenticate: aievals auth login
  2. Set your provider API key in the shell environment (OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, etc.). All environment variables are inherited by the spawned process.
  3. Name experiment files *.experiment.ts or *.experiment.py.

Basic usage

# Run a single file
aievals experiment-run run my-eval.experiment.ts

# Run all experiment files in a directory
aievals experiment-run run .

# List discovered files without executing
aievals experiment-run run . --list

Key flags

FlagDescription
--first NProcess only the first N dataset items — useful during development
--sample NRandomly sample N items
--sample-seed SSeed for reproducible sampling (default: 0)
--listDiscover and list experiment files without executing them
--filter EXPROnly run experiments whose name matches the pattern
--no-send-logsDry run — execute locally without uploading to the platform
--jsonlMachine-readable output (one JSON object per experiment) for CI/CD
--terminate-on-failureStop processing after the first failing item. On its own this does not fail CI — exit non-zero from your experiment file (e.g. on a REGRESSION verdict) to gate the pipeline
--watchRe-run on file save (incompatible with --matrix-param and --list)
--runner CMDOverride auto-detected runner (tsx, node, bun, python3)
--env-file PATHLoad environment from a specific .env file
--metadata JSONAttach metadata to the run, e.g. '{"branch":"main","pr":42}'. Git/CI context (commit, branch, author) is auto-collected separately as ciMetadata
--comparison-timeout SMax seconds to wait for baseline comparison data (default: 30)

Parameter injection

Pass named parameters to the experiment without editing the file:

# Single parameter
aievals experiment-run run . --param model=gpt-4o

# Multiple parameters
aievals experiment-run run . --param model=gpt-4o --param temperature=0.7

Parameters are injected as AIEVALS_PARAMS_JSON. The task function must read this env var explicitly; evaluators receive params automatically via a params argument.

Matrix sweep

Run a Cartesian product of parameter values in one command — the CLI creates a separate experiment run for each combination:

# 2 models × 3 temperatures = 6 runs
aievals experiment-run run . \
  --matrix-param model=gpt-4o,gpt-4o-mini \
  --matrix-param temperature=0.0,0.5,1.0

Run aievals provider list --format json to discover valid model names before using --matrix-param model=....

Verifying results

aievals experiment list                              # find the experiment
aievals experiment-run list --experiment-id <id>     # list runs
aievals experiment-run compare <run-id>              # compare to baseline
aievals experiment-run get <run-id> --format json    # full run details

See SDK: Local Experiment Runs for the SDK API used inside experiment files.


LLM evaluator tips

  • --score-range-prompt must be exactly: Provide a score ranging from 0 to 1 or Provide a discrete score of 0 or 1.
  • Do not use score list for experiment scores — it returns empty. Use the trace-based flow in the final step.
  • Do not use eval execute to debug experiment scores — use experiment-run compare instead.

Code evaluator tips

  • Shell safety: avoid !== (use !=), avoid ! in strings (use == false). For complex code, write it to a file and pass it via --code "$(cat file.js)".

Long-running operations

Commands like experiment-run create --wait poll until completion (default timeout: 10 minutes). Use --wait-timeout 300 to adjust.