Route coding agent requests to the right model on Amazon Bedrock with NVIDIA NeMo Switchyard

In one sentence

This post shows how to deploy LiteLLM with NVIDIA NeMo Switchyard via AWS CDK to route coding agent requests on Amazon Bedrock and evaluate task-level costs.

Key points

  • Coding agents operate by tasks, making cost per solved task a better routing metric than token price alone.
  • The open-source NVIDIA NeMo Switchyard library integrates with LiteLLM to support Stage routing based on tool history and Random weighted routing.
  • The solution uses AWS CDK to deploy the gateway on Amazon ECS and AWS Fargate, secured by AWS WAF and VPC interface endpoints.
  • Developers can use the sample's benchmark runners to compare the cost per solved task between routed and single-model baselines.

In depth

An AI-written overview of the original article, not the article itself.

An AWS Machine Learning Blog post explains how to route coding agent requests across models on Amazon Bedrock using the open source library NVIDIA NeMo Switchyard and LiteLLM. Because coding agents incur costs across entire multi-turn tasks rather than single calls, the article proposes judging routing by cost per solved task.

Measuring cost per solved task

According to the post, coding agents such as Claude Code and OpenAI Codex CLI work in tasks that can require anywhere from a few to dozens of model calls. Token prices alone do not capture total expenses, which depend on the number of turns, replayed history, and failed or retried attempts.

The article therefore recommends evaluating routing by cost per solved task, calculated as total run cost divided by the number of runs whose tests pass.

Architecture and routing strategies

The solution uses the AWS CDK to deploy LiteLLM with the Switchyard plugin in a container on Amazon ECS with AWS Fargate inside private subnets. Requests pass through Amazon Route 53, AWS WAF, and an Application Load Balancer before LiteLLM calls models via the Amazon Bedrock Converse or ConverseStream API.

Switchyard’s LiteLLM integration supports two strategies without requiring a judge model. Stage routing inspects recent tool activity and results in the request history to choose between a capable model, such as Claude Opus 5.5, and an efficient model, such as NVIDIA Nemotron 3 Super 120B. Random routing splits traffic by weight for A/B comparisons.

Configuration and caveats

Deployment settings live in litellm.yaml and switchyard.toml profile files, which can also define single-model baseline groups to compare cost and pass rates against the routed group. Developers can test the gateway locally with Docker Compose before deploying.

The post notes that the sample relies on experimental components, including switchyard-server 0.3.0 and LiteLLM v1.102.0, and is intended only for non-production evaluation.

Read originalOpens aws.amazon.com

This summary was generated by AI from the original article and may contain errors; the original is authoritative. Copyright belongs to the original author.

Recent stories from this source