Setup Development Environment
Setting up LLM Keys#
If you are contributing to the AG2 project, you will need an LLM key depending on the submodule you are working on.
LLM credentials are configured through individual environment variables for each provider — OPENAI_API_KEY, AZURE_OPENAI_API_KEY, GEMINI_API_KEY, and so on.
For example, to set up a Gemini API key:
Similarly, for OpenAI, Azure, Anthropic, etc.:
export OPENAI_API_KEY="<your_openai_api_key>"
export AZURE_OPENAI_API_KEY="<your_azure_api_key>"
export AZURE_OPENAI_API_BASE="<your_azure_base_url>"
export ANTHROPIC_API_KEY="<your_anthropic_api_key>"
# ...and so on for other providers
The AG2 test and tooling system picks these up automatically and constructs the required configuration for all supported LLM providers. A .env file in the repository root works too — the test suite loads it on startup.
Setting up the Development Environment#
To contribute to the AG2 project, AG2 provides two different methods to set up the development environment:
- Open the AG2 repository on GitHub and fork the repository.
- Navigate to Settings -> Secrets and variables -> Codespaces.
- Add the necessary LLM keys as mentioned above by clicking on the
New repository secretbutton. - Navigate back to the forked repository.
- Click on the
Codebutton and selectOpen with Codespaces. - Once the container is built, you can start developing AG2.
- Setup the necessary LLM keys as mentioned above in your terminal.
- Fork the AG2 repository and clone the forked repository.
- From the root of the repository, create the virtual environment and install every dependency group:
- Install the prek hooks:
- Once the dependencies are installed, you can start developing AG2.
Verifying the Development Environment#
To make sure that we have set up the development environment correctly, we can run the prek hooks and tests.
To run the prek hooks, run the following command:
To run the non-llm tests, run the following command: