Developers can now direct coding agents such as Claude Code or OpenAI Codex CLI to a LiteLLM gateway that embeds NVIDIA’s Switchyard router, which selects an Amazon Bedrock model for each request. The change is purely architectural: the agent points to a model named switchyard and the gateway decides whether to use a high‑capability or a lower‑cost model based on the request history. Practitioners care because the routing decision directly impacts the cost per completed task, not just per‑token pricing.
Solution overview
The deployment consists of a single container image that runs LiteLLM with the Switchyard plugin on Amazon ECS using the Fargate launch type. The container lives in private subnets behind an Application Load Balancer (ALB) that terminates TLS with an ACM certificate. DNS is managed in Route 53, and inbound traffic is limited to an allowed IPv4 CIDR range.
Incoming requests follow a fixed path:
- The coding agent sends an OpenAI‑compatible HTTP call to
/v1/chat/completionswith the model field set toswitchyardand includes the shared gateway key in theAuthorizationheader. - AWS WAF applies IP‑reputation, bad‑input, and per‑IP rate‑limit rules before the ALB forwards the request to the ECS task.
- LiteLLM validates the gateway key, invokes the Switchyard plugin, and the plugin selects a Bedrock model using either the stage‑routing or random‑routing strategy.
- The selected model is called via the Bedrock
ConverseorConverseStreamAPI, using the task’s IAM role for credentials.
Implementation details
The sample installs switchyard-server version 0.3.0 from crates.io and runs LiteLLM version v1.102.0. Two routing strategies are available:
- Stage routing inspects recent tool activity and results in the request history, then chooses between a capable model and a lower‑cost efficient model.
- Random routing picks a model from a weighted pool, useful for traffic splits or A/B experiments.
Both strategies operate without a separate judge model. The sample also notes that the Switchyard integration is experimental and its configuration may change between releases.
Operational and security considerations
Because the gateway terminates TLS and enforces a shared secret, secret management remains a responsibility of the deployment team. The sample explicitly advises running the code in a non‑production account, reviewing it with security and legal teams, and ensuring compliance before any production use.
Network exposure is limited to the ALB, which only forwards three paths (/v1/chat/completions, /v1/models, /health/liveliness) and returns 404 for everything else. This reduces the attack surface but does not replace a full authorization model; the gateway key is the only authentication mechanism mentioned.
Cost measurement is performed by running the provided benchmark runners, which calculate cost per solved task by dividing total spend by the number of runs whose tests pass. This metric aligns with how developers are billed for coding‑agent tasks.
Related CloudNinjas coverage: AWS.
What This Means For Practitioners
Adopting this pattern gives engineers a concrete way to experiment with model selection logic without modifying the agent itself. Teams should:
- Deploy the LiteLLM + Switchyard container in a dedicated, non‑production VPC first.
- Validate the routing strategy against representative workloads using the benchmark runner.
- Monitor the shared gateway key and rotate it regularly.
- Review WAF rules and ALB path restrictions to ensure they match the intended security posture.


