Azure AI Foundry
Use Azure AI Foundry hosted models with Agno agents.
AzureAIFoundry is Agno's classic adapter for Azure-hosted models. Its azure-ai-inference dependency retired on August 26, 2026. Existing endpoint availability is a separate question; use the current API for new projects.
Current Foundry API
For a deployment supporting Chat Completions on the current Foundry API, use OpenAILike. Copy the resource's OpenAI-compatible base URL (ending in /openai/v1), its key, and the exact deployment name from your Foundry project. Check the deployment's supported operations before choosing a model. See Microsoft's current inference example.
uv pip install -U agno openai
export FOUNDRY_API_KEY="your_resource_key"
export FOUNDRY_BASE_URL="https://your-resource.services.ai.azure.com/openai/v1"
export FOUNDRY_DEPLOYMENT="your_chat_deployment"from os import environ
from agno.agent import Agent
from agno.models.openai.like import OpenAILike
agent = Agent(
model=OpenAILike(
id=environ["FOUNDRY_DEPLOYMENT"],
api_key=environ["FOUNDRY_API_KEY"],
base_url=environ["FOUNDRY_BASE_URL"],
),
markdown=True,
)
agent.print_response("Share a two-sentence dramatic story.")The remaining sections document the classic adapter for existing integrations.
Installation
uv pip install -U azure-ai-inference aiohttp agnoAuthentication
Navigate to Azure AI Foundry on the Azure Portal and create a service. Then set your environment variables:
export AZURE_API_KEY="your_value_here"
export AZURE_ENDPOINT="your_value_here" # 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
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "gpt-4o" | The id of the model to use |
name | str | "AzureAIFoundry" | The name of the model |
provider | str | "Azure" | The provider of the model |
temperature | Optional[float] | None | Controls sampling randomness; supported values depend on the deployed model |
max_tokens | Optional[int] | None | Maximum number of tokens to generate in the response |
frequency_penalty | Optional[float] | None | Penalizes new tokens based on their frequency in the text so far (-2.0 to 2.0) |
presence_penalty | Optional[float] | None | Penalizes new tokens based on whether they appear in the text so far (-2.0 to 2.0) |
top_p | Optional[float] | None | Controls diversity via nucleus sampling (0.0 to 1.0) |
stop | Optional[Union[str, List[str]]] | None | Up to 4 sequences where the API will stop generating further tokens |
seed | Optional[int] | None | Random seed for deterministic sampling |
model_extras | Optional[Dict[str, Any]] | None | Additional model-specific parameters |
strict_output | bool | True | Accepted field; does not enable provider schema enforcement in the normal Agent output_schema path |
request_params | Optional[Dict[str, Any]] | None | Additional parameters to include in the request |
api_key | Optional[str] | None | The API key for Azure AI Foundry (defaults to AZURE_API_KEY env var) |
api_version | Optional[str] | None | The API version to use (defaults to AZURE_API_VERSION env var, then "2024-05-01-preview") |
azure_endpoint | Optional[str] | None | The Azure endpoint URL (defaults to AZURE_ENDPOINT env var) |
timeout | Optional[float] | None | Accepted field, but not forwarded by this adapter |
max_retries | Optional[int] | None | Accepted field, but not forwarded by this adapter |
http_client | Optional[httpx.Client] | None | Accepted field, but not forwarded by this adapter |
client_params | Optional[Dict[str, Any]] | None | Extra arguments forwarded to the classic Azure SDK client; use SDK-supported option names |
AzureAIFoundry is a subclass of the Model class and has access to the same params.
Supported Models
Choose from the current model catalog and check the retirement schedule. The adapter accepts a model ID; this does not guarantee availability in your region or account. Several older Llama and Cohere models used in classic examples have retired.
With the classic adapter, Agent(output_schema=...) supplies schema instructions and parses the response afterward. It does not guarantee provider-enforced output, and strict_output does not change that normal path. Check the returned content's type before consuming it. For client configuration, use supported SDK options in client_params or supply the corresponding preconfigured client or async_client.