ag2) is a framework for building multi-agent LLM applications where agents converse with each other to complete tasks. AutoGen accepts an OpenAI-compatible base_url in its config_list, so you can route all agent requests through the Portkey AI Gateway with minimal changes.
Installation
1
Start the gateway
- Local (npx)
- Portkey Cloud
http://localhost:8787/v1.2
Install dependencies
- ag2
- autogen
Basic setup
Setbase_url inside each entry of config_list to point at the gateway.
Adding routing configs via headers
Pass gateway configs throughdefault_headers inside each config list entry.
Real-world use case: multi-agent coding assistant
A three-agent group chat where each agent can use a different model, all routed through the gateway.AutoGen uses the
api_type field to determine how to format requests. Always set "api_type": "openai" when routing through the Portkey gateway, regardless of the underlying provider.