Skip to main content
LLM validators use AI models to evaluate content that can’t be easily checked with exact matching. They’re ideal for validating natural language outputs where wording may vary but meaning should be consistent.
LLM validators support transforms. Transforms are applied to the content before sending to the LLM for evaluation.

prompt!

Validates whether a natural-language statement about the output is true based on the actual text.
The prompt validator asks an LLM to check if your statement is supported by the actual output. It focuses on factual consistency rather than exact wording.
prompt! is the recommended general-purpose LLM validator. A statement has clear truth conditions (“The agent asked about the budget” is either supported by the text or it isn’t), which makes judge results more consistent than fuzzy “does it match” comparisons.

Writing Effective Statements

Write statements as specific, verifiable claims about the output. Vague statements lead to inconsistent results.
Good statements:
Avoid:
For multi-part requirements, list the parts explicitly in a single statement:

Negating prompt!

Use the negate field to assert that a statement is not true:
This passes only if the statement is not supported by the actual text.

semantic!

Uses an LLM to check if the actual value semantically matches the expected description.
The semantic validator sends the actual value and your description to an LLM, which determines if they match semantically.
If your check can be phrased as a verifiable statement, prefer prompt!. Use semantic! when you’re matching the output against a description of its overall meaning, tone, or style rather than asserting a specific fact about it.

not_semantic!

Checks that the content does NOT semantically match the description. This is the negated form of semantic!.

language!

Checks that the content is written in a specific language.

Common Language Codes

not_language!

Checks that the content is NOT written in a specific language. This is the negated form of language!.

LLM vs Exact Matching

Use LLM validation (prompt!, semantic!) when:
  • Output wording can vary but meaning must be consistent
  • Testing for tone, style, or completeness
  • Validating summaries or explanations
Use exact matching (eq!, contains!) when:
  • Specific words or phrases must appear
  • Validating structured data
  • Checking for exact values

Common Patterns

Multi-Language Support Testing

Behavioral Checks

Tone and Style Validation

Completeness Checks

Error Message Quality

Using Transforms

Transforms normalize content before LLM evaluation:

Combining with Other Validators

Choosing Models

LLM validators use Timbal agents under the hood. By default they use openai/gpt-5.4-nano, but you can override the model per-validator in YAML.
LLM validators rely on structured output. For Anthropic, structured-output support is currently in beta and only available on a limited set of models (for example: Claude Sonnet 4.5/4.6, Claude Opus 4.5/4.6, Claude Haiku 4.5). Make sure you pick one of these Anthropic variants when you set the model field.
You can otherwise pick any model supported by Timbal’s Agent – the model field here is passed directly through to the underlying agent used for the validator, subject to the provider’s structured-output limitations.

Cost Considerations

LLM validators make API calls to language models, which incur costs. To optimize:
  1. Use structural validators first: Check not_null!, contains!, etc. before LLM validation
  2. Be specific in statements: Reduces need for retries
  3. Group LLM checks: One detailed statement vs. multiple simple ones
  4. Use for critical paths: Reserve LLM validation for important behavioral checks