The core move is to route by step class, not to pick one model for the whole agent. An open-source model and a frontier model have different sweet spots, and an agent conveniently separates into steps that map onto each.
Start with a bounded task: ask a free model to call a local read-only tool, send the result back, and inspect the summary. The example above validates the tool call before executing it and stops after two model requests. It uses exact routing so an alternative model cannot change your evaluation.
The hard steps — decompose an ambiguous goal into an ordered plan, reason over a large heterogeneous context, recover from a failed multi-step sequence — are where you want a frontier model. Set the model to anthropic/claude-sonnet-4-6 or openai/gpt-4o for just that call, then drop back to the open NIM model for the rest of the loop. Because the hard steps are the rare ones, you pay frontier rates on a small slice of traffic while the $0-rate open lane absorbs the bulk.
For the heavier planning calls you can also reach for anthropic/claude-opus-4-8 or a long-context Gemini model like gemini/gemini-2.5-pro (or gemini/gemini-2.5-flash when you want a cheaper frontier option). All of them are explicit model choices through the same key and base URL. Paid access and each model's context limits still apply; the gateway does not automatically select a larger context window for your task.