FrameworksAutoGen
AutoGen
Use Nemo Router with Microsoft AutoGen for multi-agent conversations
Last updated
Microsoft's AutoGen framework supports any OpenAI-compatible endpoint via its OpenAIChatCompletionClient. Point it at Nemo Router — guardrails, caching, and rate-limits auto-apply to every agent turn.
Installation
pip install autogen-agentchat autogen-ext[openai]Setup
import os
from autogen_ext.models.openai import OpenAIChatCompletionClient
model_client = OpenAIChatCompletionClient(
model="claude-sonnet-4-20250514",
api_key=os.environ["NEMOROUTER_API_KEY"],
base_url="https://api.nemorouter.ai/v1",
)Single Agent
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.messages import TextMessage
from autogen_core import CancellationToken
async def main():
agent = AssistantAgent(
name="assistant",
model_client=model_client,
system_message="You are a concise, technical assistant.",
)
response = await agent.on_messages(
[TextMessage(content="What is an LLM gateway?", source="user")],
cancellation_token=CancellationToken(),
)
print(response.chat_message.content)
asyncio.run(main())Multi-Agent Conversation
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.conditions import MaxMessageTermination
researcher = AssistantAgent(
name="researcher",
model_client=model_client,
system_message="You research topics and surface the key facts.",
)
critic = AssistantAgent(
name="critic",
model_client=model_client,
system_message="You critique research for accuracy and depth.",
)
team = RoundRobinGroupChat(
[researcher, critic],
termination_condition=MaxMessageTermination(max_messages=6),
)
result = await team.run(task="Evaluate the state of LLM observability in 2026.")
for msg in result.messages:
print(f"{msg.source}: {msg.content}")Per-Request Overrides
Pass nemo_* fields through the client's extra_create_args:
model_client = OpenAIChatCompletionClient(
model="gpt-4o",
api_key=os.environ["NEMOROUTER_API_KEY"],
base_url="https://api.nemorouter.ai/v1",
extra_create_args={
"nemo_prompt_template_id": "your-summarizer-id",
"nemo_prompt_variables": {"language": "Spanish"},
"nemo_guardrail_ids": ["guardrail-uuid-1"],
"nemo_cache": False,
},
)Tools
AutoGen tool wiring — guardrails check the user input before tools run:
async def get_weather(city: str) -> str:
return f"72°F and sunny in {city}"
agent = AssistantAgent(
name="weather_assistant",
model_client=model_client,
tools=[get_weather],
)Next Steps
- CrewAI — Alternative multi-agent framework
- Google ADK — Google's Agent Development Kit
- Python SDK — Without AutoGen
Was this page helpful?