Skip to content

Example Walkthroughs

Here are three real-world examples of TVL modules.

1. RAG Support Bot

This example demonstrates a typical Retrieval-Augmented Generation (RAG) setup. It optimizes for quality and latency, with a structural constraint linking the model choice to the retriever configuration.

rag-support-bot.tvl.yml
--8<-- "spec/examples/rag-support-bot.tvl.yml"

2. Multi-Tenant Router

This example shows how to use TVL for a SaaS application where different user tiers (Free vs. Enterprise) have different constraints.

  • Key Feature: when user_tier = "free" then ... constraints.
multi-tenant-router.tvl.yml
--8<-- "spec/examples/multi-tenant-router.tvl.yml"

3. Cost Optimization

This example focuses on minimizing cost while maintaining a strict quality floor.

  • Key Feature: derived constraint require: quality_score >= 4.0.
cost-optimization.tvl.yml
--8<-- "spec/examples/cost-optimization.tvl.yml"