Running OpenAI models on Azure is the same as deploying your own open source model on any other cloud provider.
Prerequisites
Before you begin, ensure you have the following:- Create an Azure Account with an active subscription. Create an account here.
- Get approved access to the OpenAI Service on Azure.
- Create an Azure OpenAI resource in one of the available regions and deploy a model to it.
- Obtain the endpoint URL and API key for the OpenAI resource.
Setting Up Azure OpenAI with Agency Swarm
1
Configure the Azure OpenAI Client
To use Azure OpenAI, you need to configure the client to connect to your Azure OpenAI resource as follows:
2
Update Agent Model Parameters
Set the
model parameter inside each agent to use your custom client and model:Model deployment name might be different from the standard OpenAI model names. It is set by you when you deploy a model to Azure.
A client stored on a model outlives a single event loop: httpx2 binds pooled connections to the loop that created them, so a fixed client can crash on the next
get_response_sync. Pass http_client=loop_scoped_http_client() (from agency_swarm) when building azure_agent so its requests run on the caller’s loop. See Third-party models.3
Run Your Agency
After configuring the client and updating the agents, you can run your agency as usual:The first terminal run downloads the matching terminal app automatically.