Quick Start
Get up and running with AG2 in a few minutes. You'll install the framework, configure a model provider, and build your first agent — then give it a tool.
1. Install AG2#
Install AG2 with the extra for your model provider:
Then export your provider's API key:
2. Build your first agent#
AG2 is async throughout, so the example runs inside an async function driven by asyncio.run. Agent.ask(...) starts a turn and returns an AgentReply; read the text with reply.body.
To continue the same conversation, call ask again on the reply — it preserves context and history:
3. Give your agent a tool#
Decorate a plain Python function with @tool and pass it to the agent. AG2 manages the full tool-calling lifecycle — the model decides when to call it, AG2 executes it, and feeds the result back.
Next steps#
- Agents — the full agent communication API, streaming, and live runs.
- Models & Providers — configure OpenAI, Anthropic, Gemini, and more.
- Tools — tools, toolkits, and built-in tools.
- Multi-Agent Network — coordinate multiple agents.
- Coding with AI Assistants — set up your AI assistant to build with AG2.