Use various open source models hosted on Azure’s infrastructure. Learn more here.

Azure AI Foundry provides access to models like Phi, Llama, Mistral, Cohere and more.

Authentication

Navigate to Azure AI Foundry on the Azure Portal and create a service. Then set your environment variables:

export AZURE_API_KEY=***
export AZURE_ENDPOINT=***  # Of the form https://<your-host-name>.<your-azure-region>.models.ai.azure.com/models
# Optional:
# export AZURE_API_VERSION=***

Example

Use AzureAIFoundry with your Agent:

from agno.agent import Agent
from agno.models.azure import AzureAIFoundry

agent = Agent(
    model=AzureAIFoundry(id="Phi-4"),
    markdown=True
)

# Print the response on the terminal
agent.print_response("Share a 2 sentence horror story.")

Advanced Examples

View more examples here.

Parameters

ParameterTypeDefaultDescription
idstr-The specific model ID used for generating responses. This field is required.
namestr"AzureOpenAI"The name identifier for the agent.
providerstr"Azure"The provider of the model.
api_keyOptional[str]"None"The API key for authenticating requests to the Azure OpenAI service.
api_versionstr"2024-10-21"The version of the Azure OpenAI API to use.
azure_endpointOptional[str]"None"The endpoint URL for the Azure OpenAI service.
clientOptional[ChatCompletionsClient]NoneThe client for making requests to the Azure OpenAI service.
async_clientOptional[AsyncChatCompletionsClient]NoneThe asynchronous client for making requests to the Azure OpenAI service.
temperatureOptional[float]NoneControls randomness in the model's output. Higher values make output more random.
max_tokensOptional[int]NoneThe maximum number of tokens to generate in the response.
frequency_penaltyOptional[float]NoneReduces repetition by penalizing tokens based on their frequency.
presence_penaltyOptional[float]NoneReduces repetition by penalizing tokens that have appeared at all.
top_pOptional[float]NoneControls diversity by limiting cumulative probability of tokens considered.
stopOptional[Union[str, List[str]]]NoneSequences where the model will stop generating further tokens.
seedOptional[int]NoneRandom seed for deterministic outputs.
model_extrasOptional[Dict[str, Any]]NoneAdditional model-specific parameters.
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to pass with the request.
timeoutOptional[float]NoneTimeout in seconds for API requests.
max_retriesOptional[int]NoneMaximum number of retries for failed requests.
http_clientOptional[httpx.Client]NoneCustom HTTP client for making requests.
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration.

AzureAIFoundry is a subclass of the Model class and has access to the same params.