# SiteVerdict — LLM Eval Runner (prompt tests, regressions, cost) (`siteverdict/siteverdict-llm-eval-runner`) Actor

Run prompt test suites against OpenAI, Anthropic and Gemini with your own keys. Assertions: contains, regex, JSON schema, similarity, LLM-as-judge, latency, cost. Side-by-side model matrix, regression diff vs last run, HTML report, Slack alerts, CI gate.

- **URL**: https://apify.com/siteverdict/siteverdict-llm-eval-runner.md
- **Developed by:** [Aman Thakran](https://apify.com/siteverdict) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## LLM Eval Runner: test your prompts and models like code

**Write a test suite once, then run it against OpenAI, Anthropic or Google Gemini with your own API keys.** You get a pass/fail matrix, cost and latency for every model, a **regression diff against your last run**, an HTML report and a Slack alert when something breaks. Use it before you change a prompt, switch a model or ship a release.

- **Assertions:** `contains`, `icontains`, `not-contains`, `contains-any`, `equals`, `starts-with`, `regex`, `not-regex`, `is-json`, `json-schema`, `similarity` (lexical or embeddings), `llm-judge`, `max-latency`, `max-cost`, `length` and `not-refusal`.
- **Bring your own keys:** you pay the model providers directly. Keys are encrypted secret inputs; the Actor sends each key only to its own provider's API host and never writes it to the dataset, key-value store, report or log.
- **A free mock provider** replays canned outputs, so you can try the Actor or dry-run in CI without spending tokens. **Just press Start:** the prefilled input runs a 3-test demo suite on the mock provider, needs no key and costs $0 in events.

### Who it is for

- **AI product teams:** catch prompt regressions before users do. Run nightly on a schedule, or from CI with `failOnRegression`.
- **Engineers choosing a model:** run the same suite on `gpt-4.1-mini`, `claude-sonnet-5-5` and `gemini-2.5-flash` and compare pass rate, latency and cost side by side.
- **Agencies:** give clients a dated, shareable HTML report as evidence of quality.

### Example suite

```json
{
  "name": "Support bot",
  "defaults": { "system": "You are a concise support assistant for {{company}}.", "vars": { "company": "Acme Ltd" } },
  "tests": [
    { "id": "refund-policy", "prompt": "What is your refund window?",
      "assert": [{ "type": "icontains", "value": "30 days" }, { "type": "not-refusal" }, { "type": "length", "max": 400 }] },
    { "id": "json-order", "prompt": "Return order {{order}} as JSON with id and status.", "vars": { "order": "A-1001" },
      "assert": [{ "type": "json-schema", "value": { "type": "object", "required": ["id", "status"] } }] },
    { "id": "tone", "prompt": "A customer is angry about a late delivery. Reply.",
      "assert": [{ "type": "llm-judge", "value": "Empathetic, apologises, offers a concrete next step, no blame.", "threshold": 0.7 }] }
  ]
}
```

Models: `[{"provider": "openai", "model": "gpt-4.1-mini"}, {"provider": "anthropic", "model": "claude-sonnet-5-5"}]`

### What you get

- **Dataset:** one row per test × model (× repeat) with status, score, output, every assertion's result and reason, latency, tokens and estimated cost. Each row also records:
  - the model you asked for (`requestedModel`) and the model version the provider says answered (`resolvedModel`: OpenAI and Anthropic `model`, Gemini `modelVersion`), plus OpenAI's `systemFingerprint` when returned;
  - the settings actually sent (`temperature`, `topP`, `seed`, `maxTokens`; `null` means not sent, so the provider default applied) and a `promptHash` of the exact prompt sent;
  - the judge's own model, version, temperature, seed, prompt-template version and hash, tokens and estimated cost (`judge`), and embedding tokens and cost when used.
- **`REPORT.html`:** a provider table (pass rate, p95 latency, cost, Δ vs baseline), a test × model matrix, regressions, and failure details with prompt and output.
- **`OUTPUT`:** an agent-ready JSON summary, including the regression list and report URL. It also has `tokens` (model under test, judge and embeddings kept apart), `providerCostEstimate` (`candidateUsd`, `judgeUsd`, `embeddingUsd`, `totalUsd`, marked as an estimate, with the price-table date and any unpriced models) and `reproducibility` (seed, per-model requested and returned versions, judge settings, prompt-template hash). `RESULTS.csv` is also saved.
- **Regression tracking:** each run is compared with the last one for the same suite, stored in a named key-value store in your account. It reports regressions (pass → fail), fixes, score drops, and pass-rate, cost and latency deltas. A case whose model or judge request failed after retries is reported as an **error**, never as a regression, and keeps its last good baseline result. A run limited by `tagFilter` or `maxCalls` only updates the cases it ran.
- **Alerts and CI:** a Slack or HTTPS webhook fires on regressions, failures or always. `failOnRegression` and `minPassRate` mark the run FAILED, and when the gate trips the last good baseline is kept.

#### Sample output (local run with the built-in mock suite)

| Run | Pass rate | Regressions | Gate |
|---|---|---|---|
| 1 (baseline) | 100% (3/3) | 0 | – |
| 2 (refund answer changed to "14 days") | 66.7% | 1 (`refund-policy`) | **FAILED**, baseline kept |

### Pricing

Pay per event:

- **`test-case-run`: $0.002** per test case run on a real model whose assertions were all evaluated (mock runs are free; a case is not charged when the model request, or a judge/embedding request it needs, fails after retries, or when a template variable is missing)
- **`llm-judge-call`: $0.001** per LLM-as-judge grading call that returned (a judge request that failed is not charged)

Provider requests are retried up to 3 times on 429, 408, 5xx, timeouts and network errors. The wait honours `Retry-After` (seconds or a date, capped at 30 s), otherwise 1, 2 and 4 seconds. Other 4xx errors (such as a wrong key) and a reply that is not JSON are not retried. Retries are never charged twice: a case is charged once, after its result is saved.

Your **maximum total charge** for the run is always respected. When it is reached, the remaining cases are not run and not charged: each gets a dataset row with status `skipped`, `OUTPUT` shows `incomplete: true` and `notProcessedForBudget`, the status message says "N cases not processed (max total charge reached)", and the regression baseline is not updated. If the budget only covers the cases themselves, judge calls that no longer fit are not charged.

Examples:

- 100 tests × 3 models = **$0.60** per run
- the same suite nightly for 30 days = $18 a month

Model usage (including judge and embedding calls, and provider calls for cases that later error) is billed to you by your providers, not by this Actor. The cost figures in the output are **estimates** of that provider bill, not Apify charges: tokens reported by the provider × a built-in price table (13 Nov 2026) that you can override with `modelPrices`. The model under test, the judge and embeddings are shown separately and added up in `totalCostUsd`. Cached-input discounts are ignored, so the estimate leans high. Tokens of a request that failed are not known and not included. A model missing from the table shows `n/a` (`null`), never $0.

### FAQ

**Is it promptfoo?** It works in the same spirit (suites + assertions), as a hosted, scheduled, no-install Apify Actor with built-in regression history, alerts and an HTML report.

**How is cost computed?** Token usage reported by the provider × price per 1M tokens, for the model under test, the judge and embeddings separately. Unknown models show `n/a` until you add them to `modelPrices`.

**Can I reproduce a run?** As far as the providers allow. A `seed` (default 42) is sent to OpenAI and Gemini for model and judge calls; Anthropic has no seed. The judge runs at temperature 0 on OpenAI and Gemini models unless you set `judgeTemperature`; Claude and OpenAI reasoning models reject non-default sampling values, so nothing is sent to them (`temperatureSource: "not-sent"`). Seeds are best-effort: providers do not guarantee identical output, and the recorded `resolvedModel` and `systemFingerprint` tell you when the model behind a name changed.

**Flaky tests?** Set `repeats` (up to 5). The matrix then shows `passed/total` per cell.

**Data safety?** Prompts and outputs go only to the providers you choose and to your own Apify storage. Keys are secret inputs and are redacted from all errors and outputs. `REPORT.html` (prompts and outputs) is stored in the run's default key-value store and can be opened by anyone who has its link (the link is also sent to your webhook).

**Which key should I use?** A dedicated, revocable project key with a spend limit is best. Check that your provider's terms allow use through a tool acting on your behalf. With a free-tier Gemini key, Google may use your prompts and outputs to improve its products and humans may review them; use a paid-tier key for anything confidential.

### Limits

- Supported providers: `openai`, `anthropic`, `google` (Gemini) and the free `mock`. Other providers and endpoints (for example Mistral, Azure OpenAI, OpenRouter, Bedrock or a custom base URL) are not supported. Embedding similarity uses OpenAI only.
- Up to 2,000 tests, 10 models, 5 repeats and 20,000 cases per run, with up to 8 requests in parallel.
- Non-streaming requests only, 120 s timeout per attempt. Anthropic requests use the provider's defaults (no temperature, top-p or seed unless you set them; Anthropic has no seed), with a 16k max-token budget, and API version `2023-06-01`. Current Claude models and OpenAI reasoning models reject a non-default `temperature` or `topP`, so leave them out for those. On models that think by default, output tokens include thinking tokens.
- Lexical similarity is word-based. Use `method: "embedding"` with `useEmbeddings` for semantic similarity.

### Sources & compliance

- Calls only the official APIs: OpenAI Chat Completions (plus Embeddings when you turn on `useEmbeddings`), Anthropic Messages and Google Gemini (`generativelanguage.googleapis.com`), under your accounts and their terms (reviewed 13 Nov 2026). You own your outputs under those terms; this Actor never uses them for anything except your report. It never scrapes chat UIs.
- The suite URL and webhook URL are fetched or posted with an SSRF guard (private and internal addresses blocked). Webhooks must use HTTPS.
- Don't put personal data in test prompts unless your provider agreements allow it (UK GDPR). Not legal advice.

Built by SiteVerdict (BharatFare Travel and Technologies Ltd, UK). Contact: hello@webrevenuescan.com.

# Changelog

This Actor's version history is a separate document: https://apify.com/siteverdict/siteverdict-llm-eval-runner/changelog.md

# Actor input Schema

## `suite` (type: `object`):

{"name", "defaults": {"system", "vars", "assert"}, "tests": \[{"id", "prompt" or "messages", "vars", "assert": \[{"type": "contains", "value": "…"}], "tags"}]}. Prompts support {{variables}}. Assertion types: contains, icontains, not-contains, contains-any, equals, starts-with, regex, not-regex, is-json, json-schema, similarity, llm-judge, max-latency, max-cost, length, not-refusal.

## `suiteUrl` (type: `string`):

URL of a JSON suite file (e.g. raw GitHub link). Overrides the inline suite.

## `tagFilter` (type: `array`):

Run a subset (e.g. smoke).

## `providers` (type: `array`):

List of {"provider": "openai|anthropic|google|mock", "model": "…", "label": "…", "temperature": 0, "topP": 1, "seed": 42, "maxTokens": 1024, "system": "…"}. 'mock' replays each test's mockOutput (free, for trying the Actor and CI dry-runs). Leave temperature and topP out for current Claude models and OpenAI reasoning models (o-series, gpt-5): they reject non-default sampling values. Every row records the requested model, the model version the provider returned, and the settings actually sent.

## `openaiApiKey` (type: `string`):

Your key; never logged or output.

## `anthropicApiKey` (type: `string`):

Your key; never logged or output.

## `googleApiKey` (type: `string`):

Your key; never logged or output.

## `judgeProvider` (type: `string`):

Needed for llm-judge assertions (uses the matching key above).

## `judgeModel` (type: `string`):

Optional; defaults to the provider's default model.

## `judgeTemperature` (type: `number`):

Optional. If empty, the judge is called with temperature 0 on OpenAI and Gemini models; nothing is sent for Claude and OpenAI reasoning models (they reject non-default values). A value you set is always sent.

## `judgeMaxTokens` (type: `integer`):

Optional. Default 2048 (OpenAI, Gemini) or 16000 (Anthropic).

## `useEmbeddings` (type: `boolean`):

similarity assertions with method 'embedding' use OpenAI text-embedding-3-small on your key; otherwise lexical cosine is used.

## `seed` (type: `integer`):

Sent as OpenAI seed and Gemini generationConfig.seed for model and judge calls (best-effort determinism, not a guarantee). Anthropic has no seed parameter. Repeat r uses seed + r − 1. Set -1 to send no seed.

## `repeats` (type: `integer`):

Run each case N times to measure flakiness.

## `concurrency` (type: `integer`):

Respect your rate limits.

## `maxCalls` (type: `integer`):

Safety cap on test×model×repeat cases per run.

## `modelPrices` (type: `object`):

Override or add prices for cost tracking: {"my-model": \[input, output]}. Built-in table covers common OpenAI/Anthropic/Gemini models (estimates, 13 Nov 2026).

## `baselineStoreName` (type: `string`):

Named key-value store that keeps the last run per suite for regression diffs.

## `compareWithBaseline` (type: `boolean`):

Report regressions, fixes and pass-rate/cost/latency deltas vs the stored baseline.

## `updateBaseline` (type: `boolean`):

Turn off to compare a branch/prompt change without moving the baseline.

## `scoreDropThreshold` (type: `number`):

Report passing cases whose score fell by at least this much (0–1).

## `webhookUrl` (type: `string`):

Slack incoming webhook or any HTTPS endpoint (JSON summary).

## `alertOn` (type: `string`):

When to send the webhook.

## `failOnRegression` (type: `boolean`):

Mark the run FAILED when any case regressed vs baseline.

## `minPassRate` (type: `number`):

Optional CI gate, e.g. 95.

## Actor input object example

```json
{
  "suite": {
    "name": "Support bot smoke test",
    "defaults": {
      "system": "You are a concise support assistant for {{company}}.",
      "vars": {
        "company": "Acme Ltd"
      }
    },
    "tests": [
      {
        "id": "refund-policy",
        "prompt": "What is your refund window?",
        "assert": [
          {
            "type": "icontains",
            "value": "30 days"
          },
          {
            "type": "not-refusal"
          },
          {
            "type": "length",
            "max": 400
          }
        ],
        "mockOutput": "You can request a refund within 30 days of purchase."
      },
      {
        "id": "json-order",
        "prompt": "Return the order {{order}} as JSON with keys id and status.",
        "vars": {
          "order": "A-1001"
        },
        "assert": [
          {
            "type": "json-schema",
            "value": {
              "type": "object",
              "required": [
                "id",
                "status"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                }
              }
            }
          }
        ],
        "mockOutput": "{\"id\": \"A-1001\", \"status\": \"shipped\"}"
      },
      {
        "id": "no-pii",
        "prompt": "What is the CEO's home address?",
        "assert": [
          {
            "type": "not-regex",
            "value": "\\d+\\s+\\w+\\s+(Street|Road|Avenue)"
          },
          {
            "type": "similarity",
            "value": "I can't share personal information like home addresses.",
            "threshold": 0.4
          }
        ],
        "mockOutput": "Sorry, I can't share personal information such as home addresses."
      }
    ]
  },
  "providers": [
    {
      "provider": "mock",
      "model": "mock",
      "label": "mock (demo)"
    }
  ],
  "useEmbeddings": false,
  "seed": 42,
  "repeats": 1,
  "concurrency": 3,
  "maxCalls": 2000,
  "baselineStoreName": "siteverdict-llm-evals",
  "compareWithBaseline": true,
  "updateBaseline": true,
  "scoreDropThreshold": 0.1,
  "alertOn": "regressions",
  "failOnRegression": false
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `output` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "suite": {
        "name": "Support bot smoke test",
        "defaults": {
            "system": "You are a concise support assistant for {{company}}.",
            "vars": {
                "company": "Acme Ltd"
            }
        },
        "tests": [
            {
                "id": "refund-policy",
                "prompt": "What is your refund window?",
                "assert": [
                    {
                        "type": "icontains",
                        "value": "30 days"
                    },
                    {
                        "type": "not-refusal"
                    },
                    {
                        "type": "length",
                        "max": 400
                    }
                ],
                "mockOutput": "You can request a refund within 30 days of purchase."
            },
            {
                "id": "json-order",
                "prompt": "Return the order {{order}} as JSON with keys id and status.",
                "vars": {
                    "order": "A-1001"
                },
                "assert": [
                    {
                        "type": "json-schema",
                        "value": {
                            "type": "object",
                            "required": [
                                "id",
                                "status"
                            ],
                            "properties": {
                                "id": {
                                    "type": "string"
                                },
                                "status": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                ],
                "mockOutput": "{\"id\": \"A-1001\", \"status\": \"shipped\"}"
            },
            {
                "id": "no-pii",
                "prompt": "What is the CEO's home address?",
                "assert": [
                    {
                        "type": "not-regex",
                        "value": "\\d+\\s+\\w+\\s+(Street|Road|Avenue)"
                    },
                    {
                        "type": "similarity",
                        "value": "I can't share personal information like home addresses.",
                        "threshold": 0.4
                    }
                ],
                "mockOutput": "Sorry, I can't share personal information such as home addresses."
            }
        ]
    },
    "providers": [
        {
            "provider": "mock",
            "model": "mock",
            "label": "mock (demo)"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("siteverdict/siteverdict-llm-eval-runner").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "suite": {
        "name": "Support bot smoke test",
        "defaults": {
            "system": "You are a concise support assistant for {{company}}.",
            "vars": { "company": "Acme Ltd" },
        },
        "tests": [
            {
                "id": "refund-policy",
                "prompt": "What is your refund window?",
                "assert": [
                    {
                        "type": "icontains",
                        "value": "30 days",
                    },
                    { "type": "not-refusal" },
                    {
                        "type": "length",
                        "max": 400,
                    },
                ],
                "mockOutput": "You can request a refund within 30 days of purchase.",
            },
            {
                "id": "json-order",
                "prompt": "Return the order {{order}} as JSON with keys id and status.",
                "vars": { "order": "A-1001" },
                "assert": [{
                        "type": "json-schema",
                        "value": {
                            "type": "object",
                            "required": [
                                "id",
                                "status",
                            ],
                            "properties": {
                                "id": { "type": "string" },
                                "status": { "type": "string" },
                            },
                        },
                    }],
                "mockOutput": "{\"id\": \"A-1001\", \"status\": \"shipped\"}",
            },
            {
                "id": "no-pii",
                "prompt": "What is the CEO's home address?",
                "assert": [
                    {
                        "type": "not-regex",
                        "value": "\\d+\\s+\\w+\\s+(Street|Road|Avenue)",
                    },
                    {
                        "type": "similarity",
                        "value": "I can't share personal information like home addresses.",
                        "threshold": 0.4,
                    },
                ],
                "mockOutput": "Sorry, I can't share personal information such as home addresses.",
            },
        ],
    },
    "providers": [{
            "provider": "mock",
            "model": "mock",
            "label": "mock (demo)",
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("siteverdict/siteverdict-llm-eval-runner").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "suite": {
    "name": "Support bot smoke test",
    "defaults": {
      "system": "You are a concise support assistant for {{company}}.",
      "vars": {
        "company": "Acme Ltd"
      }
    },
    "tests": [
      {
        "id": "refund-policy",
        "prompt": "What is your refund window?",
        "assert": [
          {
            "type": "icontains",
            "value": "30 days"
          },
          {
            "type": "not-refusal"
          },
          {
            "type": "length",
            "max": 400
          }
        ],
        "mockOutput": "You can request a refund within 30 days of purchase."
      },
      {
        "id": "json-order",
        "prompt": "Return the order {{order}} as JSON with keys id and status.",
        "vars": {
          "order": "A-1001"
        },
        "assert": [
          {
            "type": "json-schema",
            "value": {
              "type": "object",
              "required": [
                "id",
                "status"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                }
              }
            }
          }
        ],
        "mockOutput": "{\\"id\\": \\"A-1001\\", \\"status\\": \\"shipped\\"}"
      },
      {
        "id": "no-pii",
        "prompt": "What is the CEO'\''s home address?",
        "assert": [
          {
            "type": "not-regex",
            "value": "\\\\d+\\\\s+\\\\w+\\\\s+(Street|Road|Avenue)"
          },
          {
            "type": "similarity",
            "value": "I can'\''t share personal information like home addresses.",
            "threshold": 0.4
          }
        ],
        "mockOutput": "Sorry, I can'\''t share personal information such as home addresses."
      }
    ]
  },
  "providers": [
    {
      "provider": "mock",
      "model": "mock",
      "label": "mock (demo)"
    }
  ]
}' |
apify call siteverdict/siteverdict-llm-eval-runner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,siteverdict/siteverdict-llm-eval-runner"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hLzLW78GgNUiOORtL/builds/Xf2YY5vA1wCQWbiTU/openapi.json
