Skip to main content

Create a virtual environment (optional)

When installing AG2 locally, we recommend using a virtual environment for the installation. This will ensure that the dependencies for AG2 are isolated from the rest of your system.

Create and activate:

To deactivate later, run:

Install AG2

AG2 requires Python version >= 3.9, < 3.14. It can be installed from pip:
If you have been using autogen or ag2, all you need to do is upgrade it using:
or
as autogen and ag2 are aliases for the same PyPI package.
openai>=1 is required.

Install Docker for Code Execution

We recommend using Docker for code execution. To install Docker, follow the instructions for your operating system on the Docker website. A simple example of how to use Docker for code execution is shown below:
To learn more about code executors, see the code executors tutorial. You might have seen a different way of defining the executors without creating the executor object, please refer to FAQ for this legacy code executor.