genai-video-router

Learn this repo in 30 minutes

A guided walkthrough. Do the steps in order. Each one has a small exercise.

Step 1: Run it (2 min)

python3 demo.py

Read scenario 1. Notice veo-3 is excluded because the user is on the creator plan. Everything else is sorted by price.

Step 2: The catalog is the product (5 min)

Open models.json. Each model has:

Exercise: change veo-3’s min_plan from "pro" to "creator" and rerun. Veo now appears in scenario 1’s try order. You just changed packaging without touching code.

Step 3: Hard vs soft rules (8 min)

Open router/resolver.py.

Exercise: in auto mode we sort by cost. What if you sorted by priority first instead? Would quality or margin change? (This is exactly the kind of tradeoff a PM owns.)

Step 4: Which errors deserve a retry (8 min)

Open router/runner.py and read classify().

Status Meaning Decision
timeout, 429, 5xx Vendor is struggling Retryable: try the next one
400, 451 Your request is the problem Permanent: stop

Exercise: in demo.py, change scenario 4’s "content_policy" to "rate_limit" and rerun. Watch it fail over instead of stopping.

Step 5: Tests are your spec (5 min)

python3 -m unittest -v

Open tests/test_router.py. Each test name reads like a requirement: test_permanent_error_stops_and_bills_nothing. Tests are acceptance criteria that run themselves.

Exercise: break something on purpose (make classify return RETRYABLE for everything), run the tests, and see which requirement fails. Then undo it.

Step 6: Explain it in an interview (2 min)

Practice saying this out loud:

“We routed across several video models and vendors from one config file. Hard constraints filter, soft preferences order. Outages fail over, bad requests stop immediately, and users always pay the quoted price, so the cost of vendor unreliability shows up on our margin, where we can manage it, not on the customer’s bill.”