This repository contains samples showing different Python stacks for building on top of multiple Microsoft Foundry models (OpenAI, Claude, etc). Each example demonstrates the same task — calling a Foundry-hosted model — using a different Python SDK or framework.
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.
You can run this repository virtually by using GitHub Codespaces. The button will open a web-based VS Code instance in your browser:
-
Open the repository (this may take several minutes):
-
Open a terminal window
-
Continue with the steps to run the examples
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
-
Make sure the following tools are installed:
- Python 3.10+
- uv
- Git
-
Clone the repository:
git clone https://github.com/pamelafox/python-stack-foundry-models cd python-stack-foundry-models -
Install the dependencies:
uv sync
All examples use models hosted on Microsoft Foundry. The project includes infrastructure as code (IaC) to provision OpenAI and Claude deployments. 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
If you are using a tenant besides the default tenant, you may need to also login with Azure CLI to that tenant:
az login --tenant your-tenant-id
-
Provision the Foundry resources:
azd provision
It will prompt you to provide an
azdenvironment name (like "stack-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
.envfile with all the environment variables needed to run the scripts. -
To delete the resources, run:
azd down
You can run the examples in this repository by executing the scripts in the examples directory. Each example demonstrates calling Foundry models using a different Python stack.
| Example | Description |
|---|---|
| openai_responses.py | Calling a Foundry-hosted OpenAI model using the OpenAI Python SDK (Responses API). |
| anthropic_messages.py | Calling a Foundry-hosted Claude model using the Anthropic Python SDK (Messages API). |
| litellm_swap.py | Calling either OpenAI or Claude models via LiteLLM, a unified interface that abstracts provider differences. |
| pydanticai_agent.py | Building an agent with tools using PydanticAI, configured for either OpenAI or Claude on Foundry. |
| langchain_agent.py | Building an agent with tools using LangChain, configured for either OpenAI or Claude on Foundry. |
| agentframework_agent.py | Building an agent with tools using Microsoft Agent Framework, configured for either OpenAI or Claude on Foundry. |
Run any example with:
uv run examples/<example_name>.py