FAL_KEY (auto-injected into every runner) to call the backends via the fal client SDK. The router runs on cheap CPU instances and adds minimal latency, while each backend scales independently based on its own traffic. For simpler cases where you just want requests routed to runners that already have the right model loaded, see Optimize Routing Behavior instead.
When to Use
- Route by GPU requirements — Send small inputs to A100, large inputs to H100
- Route by model variant — Different LoRA adapters, different base models
- A/B testing — Split traffic between model versions
- Multi-step pipelines — Orchestrate a chain of apps (preprocess, generate, postprocess)
- Fallback routing — Try one app, fall back to another on failure
- Cost optimization — Route simple requests to cheaper machines, complex ones to expensive
How It Works
- Deploy multiple backend apps, each on a specific machine type
- Deploy a lightweight CPU router app that accepts all requests
- The router inspects the input and calls the appropriate backend via
fal_client FAL_KEYis auto-injected into every runner, so the router can call other fal apps without hardcoding credentials
Example: Route by Input Size
Three apps: a CPU router and two GPU backends for different resolutions.Backend Apps
Router App
image-router — it routes to the right backend automatically.
Example: A/B Testing
Split traffic between two model versions:Example: Multi-Step Pipeline
Chain multiple apps together:Trade-offs
Related
Optimize Routing Behavior
Route requests within a single app using runner hints
Environment Variables
FAL_KEY is auto-injected for calling other fal apps