Cookbook¶
Ready-to-use recipes for common and edge-case scenarios. All examples are
plain Tera templates you drop into your --config-dir. The bundled
examples/templates/ directory in the repo has 20+ more.
Conditional logic¶
Return a different answer based on the user's message:
{
"id": "chatcmpl-{{ uuid() }}",
"choices": [{
"message": {
"role": "assistant",
"content": "{% if json.messages | last | get(key='content') | lower is containing('error') %}I am simulating an error scenario for you.{% else %}Everything looks normal.{% endif %}"
},
"finish_reason": "stop"
}]
}
Maintenance / overloaded mode¶
Pair this template with error_template and a 503 status_code so it's
returned as a real failure (see
Chaos & error injection):
{
"error": {
"message": "The model is currently overloaded. Please try again later.",
"type": "server_error",
"code": "model_overloaded"
}
}
Fuzzing / large payloads¶
Stress your client's buffers and UI with bulk random data:
{
"id": "fuzz-{{ uuid() }}",
"choices": [{
"message": {
"role": "assistant",
"content": "{% for i in range(end=100) %}FUZZ_{{ random_int(min=0, max=999999) }} {% endfor %}"
},
"finish_reason": "stop"
}]
}
Non-JSON content types¶
VidaiMock isn't only for JSON — set --content-type and serve anything.
CSV (RAG ingestion tests):
id,name,role,created_at
{{ uuid() }},Alice,Admin,{{ iso_timestamp() }}
{{ uuid() }},Bob,User,{{ iso_timestamp() }}
SOAP/XML (legacy enterprise mocks):
<?xml version="1.0"?>
<soap:Envelope>
<soap:Body>
<Response><Id>{{ uuid() }}</Id><Status>OK</Status></Response>
</soap:Body>
</soap:Envelope>
Agentic loop (zero-token CI)¶
The flagship recipe — drive an ADK / LangGraph / LangChain Runner loop end-to-end with no live tokens. The bundled chat template already does this; see Agentic workflow testing for the full two-turn round trip.
Forced upstream failure for fallback tests¶
Register a "broken" and a "healthy" upstream against the same instance:
The system under test can't tell it's the same mock. See Chaos & error injection.
More¶
The repo's examples/ directory ships 20+ advanced templates — RAG
citations, structured math solving, GraphQL, HTML pages, security fuzzing,
and more. They're bundled in every release archive.