Python AI Agent Frameworks Demos

This repository provides examples of many popular Python AI agent frameworks.
Getting started
You have a few options for getting started with this repository.
The quickest way to get started is GitHub Codespaces, since it will setup everything for you, but you can also set it up locally.
GitHub Codespaces
You can run this repository virtually by using GitHub Codespaces. Click one of the buttons below to open a web-based VS Code instance in your browser:
Default (Azure OpenAI):

Ollama (local models, requires 64GB+ memory):

The Ollama Codespace pre-installs Ollama and pulls the gemma4:e4b model, and copies .env.sample.ollama as your .env file. Note that the 64GB memory requirement will consume your Codespace quota faster.
Once the Codespace is open, open a terminal window and continue with the steps to run the examples.
VS Code Dev Containers
A related option is VS Code Dev Containers, which will open the project in your local VS Code using the Dev Containers extension:
-
Start Docker Desktop (install it if not already installed)
-
Open the project:

-
In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window.
-
Continue with the steps to run the examples
Local environment
-
Make sure the following tools are installed:
-
Clone the repository:
git clone https://github.com/Azure-Samples/python-ai-agent-frameworks-demos
cd python-ai-agent-frameworks-demos
-
Set up a virtual environment:
-
Create a virtual environment and install dependencies:
uv sync
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Configuring model providers
These examples can be run with Azure OpenAI account, OpenAI.com, or local Ollama server, depending on the environment variables you set. All the scripts reference the environment variables from a .env file, and an example .env.sample file is provided. Host-specific instructions are below.
Using Azure OpenAI models
To run the examples using models from Azure OpenAI, you need to provision the Azure AI resources, which will incur costs.
This project includes infrastructure as code (IaC) to provision Azure OpenAI deployments of “gpt-5.4” and “text-embedding-3-large”. The IaC is defined in the infra directory and uses the Azure Developer CLI to provision the resources.
-
Make sure the Azure Developer CLI (azd) is installed.
-
Login to Azure:
azd auth login
For GitHub Codespaces users, if the previous command fails, try:
azd auth login --use-device-code
-
Provision the OpenAI account:
azd provision
It will prompt you to provide an azd environment name (like “agents-demos”), select a subscription from your Azure account, and select a location. Then it will provision the resources in your account.
-
Once the resources are provisioned, you should now see a local .env file with all the environment variables needed to run the scripts.
-
To delete the resources, run:
azd down
-
Create a .env file by copying the .env.sample file and updating it with your OpenAI API key and desired model name.
cp .env.sample .env
-
Update the .env file with your OpenAI API key and desired model name:
API_HOST=openai
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o-mini
Using Ollama models
-
Install Ollama and follow the instructions to set it up on your local machine.
-
Pull a model, for example:
ollama pull qwen3:30b
Note that most models do not support tool calling to the extent required by agents frameworks, so choose a model accordingly.
-
Create a .env file by copying the .env.sample file and updating it with your Ollama endpoint and model name.
cp .env.sample .env
-
Update the .env file with your Ollama endpoint and model name (any model you’ve pulled):
API_HOST=ollama
OLLAMA_ENDPOINT=http://localhost:11434/v1
OLLAMA_MODEL=gemma4:e4b
Running the Python examples
You can run the examples in this repository by executing the scripts in the examples directory. Each script demonstrates a different AI agent pattern or framework.
Microsoft Agent Framework
Langchain v1 and LangGraph
OpenAI and OpenAI-Agents
PydanticAI
Other frameworks
| Example |
Description |
| llamaindex.py |
Uses LlamaIndex to build a ReAct agent for RAG on multiple indexes. |
Resources
评论