Documentation Index
Fetch the complete documentation index at: https://evalgate.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Built-in assertion library for LLM outputs
20+ purpose-built assertions for LLM outputs: text content, safety, JSON structure, quality, and numeric checks. Use in test suites or standalone.The assertion library gives you 20+ purpose-built checks for LLM outputs — covering content correctness, safety, structure, style, and performance. Import
expect from @evalgate/sdk (TypeScript) or evalgate_sdk (Python) and chain assertion methods directly against any string or value your model produces.
Import
Text and content
These assertions check what the output contains, matches, or excludes.toEqual(expected) / to_equal(expected)
toEqual(expected) / to_equal(expected)
expected.toContain(substring) / to_contain(substring)
toContain(substring) / to_contain(substring)
substring as a literal substring.toContainKeywords(keywords[]) / to_contain_keywords(keywords[])
toContainKeywords(keywords[]) / to_contain_keywords(keywords[])
toNotContain(substring) / to_not_contain(substring)
toNotContain(substring) / to_not_contain(substring)
substring.toMatchPattern(regex) / to_match_pattern(regex)
toMatchPattern(regex) / to_match_pattern(regex)
toHaveLength({ min, max }) / to_have_length({ min, max })
toHaveLength({ min, max }) / to_have_length({ min, max })
Safety and compliance
These assertions catch outputs that could expose sensitive data or violate content policies.toNotContainPII() / to_not_contain_pii()
toNotContainPII() / to_not_contain_pii()
toBeProfessional() / to_be_professional()
toBeProfessional() / to_be_professional()
toNotHallucinate(facts[]) / to_not_hallucinate(facts[])
toNotHallucinate(facts[]) / to_not_hallucinate(facts[])
facts[] must be grounded in the output. This is a local, heuristic check. Use toNotHallucinateAsync() for an LLM-backed verification.JSON and structure
These assertions verify the shape and contents of structured outputs.toBeValidJSON() / to_be_valid_json()
toBeValidJSON() / to_be_valid_json()
toMatchJSON(schema) / to_match_json(schema)
toMatchJSON(schema) / to_match_json(schema)
schema must be present in the parsed JSON output.toContainCode() / to_contain_code()
toContainCode() / to_contain_code()
Quality and style
These assertions check the tone and grammatical correctness of the output.toHaveSentiment(type) / to_have_sentiment(type)
toHaveSentiment(type) / to_have_sentiment(type)
type. Accepted values: 'positive', 'negative', 'neutral'.toHaveProperGrammar() / to_have_proper_grammar()
toHaveProperGrammar() / to_have_proper_grammar()
Numeric and performance
These assertions are useful for checking latency, numeric scores, or any value-based property of your AI system.toBeFasterThan(ms) / to_be_faster_than(ms)
toBeFasterThan(ms) / to_be_faster_than(ms)
ms milliseconds.toBeGreaterThan(n) / to_be_greater_than(n)
toBeGreaterThan(n) / to_be_greater_than(n)
n.toBeLessThan(n) / to_be_less_than(n)
toBeLessThan(n) / to_be_less_than(n)
n.toBeBetween(min, max) / to_be_between(min, max)
toBeBetween(min, max) / to_be_between(min, max)
[min, max].toBeTruthy() / to_be_truthy()
toBeTruthy() / to_be_truthy()
toBeFalsy() / to_be_falsy()
toBeFalsy() / to_be_falsy()
Tagging assertions by cost tier
UsewithCostTier() to mark each assertion by its execution cost. This lets the runner skip expensive LLM-backed checks in fast feedback loops and include them in nightly or CI runs.
'code' (local, instant) and 'llm' (backed by an LLM judge call).
LLM-backed hallucination check
toNotHallucinateAsync() sends the output and facts to a judge model for a deeper grounding check. It is async and counts against your judge token budget:
toNotHallucinateAsync() requires a configured judge. Make sure EVALGATE_API_KEY is set before calling it.Using assertions in a test suite
The most common pattern is to pass assertions as functions insidecreateTestSuite cases. Each assertion receives the executor’s output and returns a result: