An AutoGen team is a conversation, and every turn of it is a model call. Researcher speaks, critic answers, researcher revises. The calls are small; the run is not. And when each agent file wires up its own client, the operational questions — what did that run cost, what happens when the model errors mid-conversation, what stops a loop — end up answered in five places, or none.

AutoGen's design gives them one place to live. Agents don't construct their own clients. An AssistantAgent receives a model_client, and a whole team can share one. That object is the seam.

The one definition

pip install autogen-agentchat autogen-ext[openai] nrouter-sdk 
import os from autogen_ext.models.openai import OpenAIChatCompletionClient model_client = OpenAIChatCompletionClient( model="claude-sonnet-4-5-20250929", api_key=os.environ["NROUTER_API_KEY"], base_url="https://api.nrouter.ai/v1", timeout=60.0, max_retries=2, extra_create_args={"extra_body": {"nrouter_cache": True}}, ) 

The model string stays bare — no provider prefix — because the client speaks the OpenAI wire format to the gateway endpoint. Hand this client to every agent and the team's traffic shares one configuration.

What doesn't change

The team. AssistantAgent still takes a name, a system message and the model_client. RoundRobinGroupChat still takes its turns in order. MaxMessageTermination(max_messages=4) still ends the conversation, and the run still ends with await team.run(task=...). Team design is AutoGen's job and it stays AutoGen's.

What the gateway carries

  • Fallbacks as configuration. Per-call overrides ride inside extra_create_args, in the extra_body: nrouter_fallbacks names the chain, or nrouter/auto with nrouter_optimize set to quality, balanced or cost (plus nrouter_cost_band under cost) lets routing decide per call.
  • A ceiling for the spend, beside the cap on turns. MaxMessageTermination bounds the conversation; it doesn't bound the money. Hard budget ceilings on the virtual key are checked before a call runs, so a team that reaches its ceiling stops with a legible refusal instead of iterating through the weekend.
  • A record per call. Responses carry x-nr-request-id, x-nr-model, x-nr-cost-status and x-nr-request-cost. Across a run, that's attribution: which model served which turn, at what settled cost.
  • Typed errors. A guardrail block surfaces as openai.BadRequestError; a rate limit arrives as openai.RateLimitError, asking for a backoff. The code around the run can tell them apart and react differently.

A team is a workload with a shape — turn-based, bursty, occasionally circular. Governing it at the one client every agent shares is simply meeting the workload where it already gathers.

Full walkthrough: AutoGen guide