Route coding agent requests to the right model on Amazon Bedrock with NVIDIA NeMo Switchyard NVIDIA released NeMo Switchyard, an open source library that lets coding agents such as Claude Code and OpenAI Codex CLI route each request to a chosen model, with a LiteLLM integration supporting stage routing and random routing. An AWS sample deploys LiteLLM with the Switchyard plugin on Amazon ECS and AWS Fargate to call models on Amazon Bedrock, installing switchyard-server 0.3.0 from crates.io and the LiteLLM v1.102.0 image, and uses benchmark runners to measure cost per solved task against single-model baselines. NVIDIA documents switchyard-server 0.3.0 as a demo and evaluation component whose configuration can change between releases, and the sample is designated non-production code. Artificial Intelligence https://aws.amazon.com/blogs/machine-learning/ Route coding agent requests to the right model on Amazon Bedrock with NVIDIA NeMo Switchyard Coding agents such as Claude Code and OpenAI Codex CLI work in tasks. A developer asks for a change, and the agent reads files, edits code, and runs tests until the work is done. One task can take a few model calls or dozens. What the developer pays for is the task, not one call. The price per token alone doesn’t tell you what a whole task costs. The total depends on how many turns a model needs, how much history each turn replays, and how often a task has to be retried or never finishes. You pay for every attempt, including attempts on tasks that never finish. So when you route a coding agent’s requests between models, judge the routing by cost per solved task: the total cost of your runs divided by the number of runs whose tests pass. NVIDIA NeMo Switchyard https://github.com/NVIDIA-NeMo/Switchyard is an open source library that helps an AI agent choose which model handles each request. You define the models that it can use and the strategy that it follows. Its LiteLLM integration https://github.com/NVIDIA-NeMo/Switchyard/blob/21075c6652152dac88a5fbc6b878ca37d7617c1c/examples/litellm/README.md supports two strategies. Stage routing reads the recent tool activity and results in the request history, and then picks one of two candidate models. Random routing picks from the configured models, with optional weights, for traffic splits and A/B comparisons. Another option you can explore is LiteLLM, who also recently shipped a native built-in Switchyard stage router https://docs.litellm.ai/blog/switchyard-tool-aware-routing as an auto-router strategy. In this post, you use the AWS Cloud Development Kit AWS CDK to deploy LiteLLM, an open source gateway for large language models LLMs , with the Switchyard routing plugin in your AWS account. LiteLLM calls the models on Amazon Bedrock https://aws.amazon.com/bedrock/ . You then use the sample’s benchmark runners to measure cost per solved task for a routed model group and for single-model baseline groups, so that you can evaluate routing against your own workloads. Note: The sample installs switchyard-server 0.3.0 from crates.io and runs the published LiteLLM v1.102.0 image. NVIDIA documents switchyard-server 0.3.0 as a demo and evaluation component, and its configuration can change between releases. This sample uses the experimental Switchyard LiteLLM integration and its configuration and APIs may change between releases. This is sample code, for non-production usage. Work with your security and legal teams to meet your organizational security, regulatory, and compliance requirements before deployment. Deploy the sample in a non-production account and test it before relying on it. Solution overview Figure 1 shows the architecture of the solution. LiteLLM and the Switchyard plugin run in one container image on Amazon Elastic Container Service Amazon ECS https://aws.amazon.com/ecs/ on AWS Fargate https://aws.amazon.com/fargate/ , in private subnets. A request flows through these steps. The numbers match the diagram. 1. The coding agent sends an OpenAI-compatible request with the model field set to switchyard , the LiteLLM model group that Switchyard routes, and the shared gateway key in the Authorization header. The endpoint is your hostname over HTTPS, with an AWS Certificate Manager ACM https://aws.amazon.com/certificate-manager/ certificate on the load balancer, and only the IPv4 CIDR range that you allow can reach it. With a hosted zone in Amazon Route 53 https://aws.amazon.com/route53/ , Route 53 resolves the hostname to the load balancer. 2. AWS WAF https://aws.amazon.com/waf/ filters the request with IP reputation, known bad input, and per-IP rate-limit rules. The Application Load Balancer https://aws.amazon.com/elasticloadbalancing/application-load-balancer/ forwards only /v1/chat/completions , /v1/models , and /health/liveliness to the ECS task in a private subnet, and answers every other path with 404. 3. The task runs one container: LiteLLM with the embedded Switchyard plugin. LiteLLM validates the gateway key and calls the plugin to pick a model. Stage chooses between a capable model and a lower-cost efficient model. It reads the tool activity and results in the request history, so the agent must send the full conversation history. Random chooses from a weighted pool. Neither strategy calls a judge model. 4. LiteLLM calls the selected model through the Amazon Bedrock Converse or ConverseStream API, with the task’s AWS Identity and Access Management IAM https://aws.amazon.com/iam/ role for credentials. The call goes through an Amazon Bedrock Runtime interface endpoint in the Amazon Virtual Private Cloud Amazon VPC https://aws.amazon.com/vpc/ , so inference traffic stays on the AWS network. 5. The response or token stream returns through LiteLLM and the load balancer. The x-litellm-model-name response header names the model that answered. The response body’s model field stays switchyard . LiteLLM listens on port 4000 in the container and is the load balancer’s target, and the task’s security group admits only the load balancer. The path allowlist keeps the LiteLLM admin UI, API docs, and key management routes unreachable. Amazon Elastic Container Registry Amazon ECR https://aws.amazon.com/ecr/ holds the gateway image. AWS Secrets Manager https://aws.amazon.com/secrets-manager/ generates the secret behind the gateway key, and the container adds the sk- prefix when it starts. The task definition passes the profile files in LITELLM CONFIG TEXT and SWITCHYARD CONFIG TEXT , and the startup script writes them to /tmp before it starts LiteLLM. Logs go to one Amazon CloudWatch https://aws.amazon.com/cloudwatch/ log group, /