Capstone: A Production Multi-LLM Gateway End-to-End

12 min read Module 10 of 10 Lesson 28 of 28

What you'll learn

  • Combine routing, reliability, caching, governance, and observability into one coherent gateway configuration for a realistic multi-team scenario
  • Justify each design decision against a concrete requirement rather than including a feature because it was covered in the course
  • Produce a config.yaml and supporting code that could plausibly be reviewed and approved by a real platform team
  • Identify what is deliberately out of scope for a first production version versus what genuinely cannot be deferred
Building this at your company? For enterprise and company teams taking this to production: book a 30-minute session with our AI engineers for architecture guidance, code review, and a rollout plan for your use case.
Book a Team Session

Every lesson in this course built one layer of a gateway in isolation. This capstone combines all of them into a single, coherent system for a realistic scenario: Meridian, a mid-size logistics company running a customer support bot, an internal engineering copilot, and a fraud-detection service, all routing through one gateway.

The Requirements

  • Support bot (customer-facing): needs the highest available quality, a $2,000/month budget, and must survive a full outage of the primary cloud region without going down entirely.
  • Internal engineering copilot: needs frontier-model access for complex reasoning, a $500/month budget, and audit logging (some engineers work with regulated customer data in prompts).
  • Contractor access (a rotating set of short-term contractors): restricted to a self-hosted open-weight model only, capped at $20/month, no exceptions.
  • Company-wide: PII must never reach an external provider unredacted; every team’s spend must be attributable in a monthly report; quality must be monitored so a silent provider-side model change doesn’t go unnoticed.

Assembling the Config

model_list:
  # Support bot: primary + fallback, prioritizing availability (Lesson 14)
  - model_name: support-chat
    litellm_params: {model: anthropic/claude-sonnet-4-5, api_key: os.environ/ANTHROPIC_API_KEY, order: 1}
  - model_name: support-chat
    litellm_params: {model: openai/gpt-4o, api_key: os.environ/OPENAI_API_KEY, order: 2}
  - model_name: support-chat
    litellm_params: {model: hosted_vllm/meta-llama/Llama-3.1-8B-Instruct, api_base: http://vllm-internal:8000/v1, api_key: "none", order: 3}

  # Internal copilot: frontier access, latency-aware between two comparable options (Lesson 11)
  - model_name: internal-copilot
    litellm_params: {model: anthropic/claude-sonnet-4-5, api_key: os.environ/ANTHROPIC_API_KEY}
  - model_name: internal-copilot
    litellm_params: {model: openai/gpt-4o, api_key: os.environ/OPENAI_API_KEY}

  # Contractor pool: self-hosted only, no cloud provider access at all
  - model_name: contractor-safe
    litellm_params: {model: hosted_vllm/meta-llama/Llama-3.1-8B-Instruct, api_base: http://vllm-internal:8000/v1, api_key: "none"}

router_settings:
  routing_strategy: latency-based-routing   # Lesson 11: internal-copilot picks the faster of two comparable models
  redis_host: redis-service                  # Lesson 25: shared state across replicas

litellm_settings:
  fallbacks:
    - support-chat: []                       # already expressed via order above; retained for clarity
  num_retries: 2
  cache: true                                # Lesson 16: exact-match caching on by default
  cache_params: {type: redis, similarity_threshold: 0.95}  # Lesson 16: semantic cache threshold

general_settings:
  master_key: os.environ/GATEWAY_MASTER_KEY

Wiring Governance and Observability Around It

# Team/key setup (Lesson 19), run once at provisioning time
TEAMS = {
    "support-bot":        {"models": ["support-chat"], "max_budget": 2000},
    "internal-eng":       {"models": ["internal-copilot"], "max_budget": 500},
    "contractors":        {"models": ["contractor-safe"], "max_budget": 20},
}

# Every request path: PII redaction (Lesson 20) before routing, audit log
# (Lesson 21) on every outcome, cost logging (Lesson 18) at egress
def handle_gateway_request(request, key_metadata):
    request = gateway_pre_call_hook(request)          # PII redaction, Lesson 20
    try:
        check_budget_before_call(key_metadata["key_id"], estimate_cost(request))  # Lesson 18
    except PermissionError as e:
        write_audit_entry(AuditLogEntry(..., outcome="rejected_budget", detail=str(e)))
        raise

    response = router.completion(**request)            # Module 4 routing + Module 5 reliability

    cost = compute_cost_from_usage(response)            # Lesson 18
    log_request_cost(key_metadata, response.model, cost, now())
    write_audit_entry(AuditLogEntry(..., outcome="success", cost_usd=cost))

    maybe_score_response(response.model, request, response)  # Lesson 23: sampled quality monitoring
    return response

Deployment and Resilience

flowchart TD
    subgraph USEast["us-east (primary region)"]
        GWEast["Gateway replicas\n(K8s Deployment, Lesson 25)"]
    end
    subgraph EUWest["eu-west (failover region)"]
        GWWest["Gateway replicas"]
    end
    DNS["Geo DNS / health-check failover\n(Lesson 26)"]
    DNS --> GWEast
    DNS -.->|"failover if us-east unreachable"| GWWest

    SupportBot["Support bot"] --> DNS
    Copilot["Internal copilot"] --> DNS
    Contractors["Contractor tools"] --> DNS

    style DNS fill:#4338CA,stroke:#4338CA,color:#ffffff,rx:8px,ry:8px
    style GWEast fill:#EEF0F7,stroke:#6366F1,color:#0F172A,rx:8px,ry:8px
    style GWWest fill:#EEF0F7,stroke:#6366F1,color:#0F172A,rx:8px,ry:8px

The support-chat model’s three-tier order (Lesson 14) handles a single provider or deployment failing; the two-region topology with geo-DNS failover (Lesson 26) handles the harder case of the whole primary region’s gateway becoming unreachable, a scenario the in-process fallback chain alone has no visibility into. Both are present because the requirement, “must survive a full regional outage,” specifically demanded the layer that fallback chains alone don’t cover.

What’s Deliberately Out of Scope for Launch

A real rollout distinguishes what a launch cannot safely operate without from what improves the system over time. This capstone’s first version ships with authorization, budgets, PII redaction, basic fallback, and audit logging, the mechanisms whose absence would be a safety or correctness gap. It explicitly defers a full LLM-as-judge drift-monitoring pipeline (Lesson 23) and a live A/B rollout process (Lesson 24) to a fast-follow phase: their absence at launch is a cost-optimization and quality-improvement gap, not a reason traffic can’t safely flow through the gateway on day one. Scoping a launch this way, and being able to articulate why each deferred piece is safe to defer, is itself a skill this course was building toward as much as any single lesson’s mechanism.

That is the complete arc: from Lesson 1’s four production failures that motivated a gateway at all, through the request lifecycle and schema that make routing possible, the LiteLLM build, the routing strategies, the reliability engineering, the cost and governance controls, the observability layer, and finally deployment at scale, culminating in one system that has to satisfy all of it at once, exactly as a real platform team’s gateway does.

Knowledge Check

3 questions to test your understanding

1 The capstone scenario has a 'contractor' role restricted to a self-hosted model with a $20/month budget, and an 'internal-eng' role with access to frontier models and a $500/month budget. Which lessons' mechanisms directly implement this requirement?

2 The capstone requires that a full outage of the primary cloud region not take down support-bot traffic entirely. Which two lessons' mechanisms combine to satisfy this, and why does it take both rather than just one?

3 Why is it appropriate for a first production version of this capstone gateway to explicitly defer semantic caching (Lesson 16) and LLM-as-judge drift monitoring (Lesson 23) to a fast-follow phase, rather than needing every course lesson's mechanism in the initial launch?

Go further with expert guidance

Ready to build production AI?
Talk to our R&D team.

These courses give you the foundation. Our embedded AI teams take you from prototype to production in 30–90 days, with your team, your codebase, your goals. Book a free strategy call to see how we can accelerate your AI initiative.

30 minutes · No obligation · Expert AI engineers, not sales reps

AI Architecture Review

Audit your current stack and identify high-impact improvements

Project Review

Get expert feedback on your AI implementation and codebase

Team Mentoring

Upskill your engineers with hands-on AI coaching sessions

AI Strategy

Define your AI roadmap, prioritization, and implementation plan