code · freepromptfoodeterministicmirrors promptfoo starts-with
Starts with
Starts with checks that the output begins with the expected string, ignoring case and surrounding whitespace. It mirrors promptfoo's `starts-with` and is free.
Run this example in the console runs in code · $0
What the evaluator does
Both strings are trimmed and lower-cased; the output must begin with the expected text.
frame 1/4 · the two inputs
output
Yes — the refund was issued on Monday.
expected
yes
1.trim and lower-case
2.compare the prefix
starts withscore 1
runs in code · $0 · ~0 ms · deterministic
Reach for it when
- Required openers: a greeting, a status word, a JSON opening brace.
- Detecting preambles you do not want (invert the pass in your pipeline).
Not the right tool when
- The opener may be paraphrased (use llm_judge with a rubric).
Watch out for
- Markdown or code fences before the real content will fail the check; decide whether that is desired.
What to send
required fields
outputexpected
optional fields
none
in suites
PromptfooEverything
result shape
score 0–1 computed in code, label, passed at an evaluator-specific threshold, no probabilities.
POST /api/v1/evaluateopen in console
{
"evaluators": [
"starts_with"
],
"output": "Yes — the refund was issued on Monday.",
"expected": "yes"
}expected
Prefix present: score 1.
Aggregate with
One result per item is a fact; a dataset of them is a metric. These are the aggregations that fit this evaluator's output shape.
- Is starts_with case-sensitive?
- No. Both sides are lower-cased first.