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"
foundry_agent.py
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 agno

Authentication

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

ParameterTypeDefaultDescription
idstr"gpt-4o"The id of the model to use
namestr"AzureAIFoundry"The name of the model
providerstr"Azure"The provider of the model
temperatureOptional[float]NoneControls sampling randomness; supported values depend on the deployed model
max_tokensOptional[int]NoneMaximum number of tokens to generate in the response
frequency_penaltyOptional[float]NonePenalizes new tokens based on their frequency in the text so far (-2.0 to 2.0)
presence_penaltyOptional[float]NonePenalizes new tokens based on whether they appear in the text so far (-2.0 to 2.0)
top_pOptional[float]NoneControls diversity via nucleus sampling (0.0 to 1.0)
stopOptional[Union[str, List[str]]]NoneUp to 4 sequences where the API will stop generating further tokens
seedOptional[int]NoneRandom seed for deterministic sampling
model_extrasOptional[Dict[str, Any]]NoneAdditional model-specific parameters
strict_outputboolTrueAccepted field; does not enable provider schema enforcement in the normal Agent output_schema path
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to include in the request
api_keyOptional[str]NoneThe API key for Azure AI Foundry (defaults to AZURE_API_KEY env var)
api_versionOptional[str]NoneThe API version to use (defaults to AZURE_API_VERSION env var, then "2024-05-01-preview")
azure_endpointOptional[str]NoneThe Azure endpoint URL (defaults to AZURE_ENDPOINT env var)
timeoutOptional[float]NoneAccepted field, but not forwarded by this adapter
max_retriesOptional[int]NoneAccepted field, but not forwarded by this adapter
http_clientOptional[httpx.Client]NoneAccepted field, but not forwarded by this adapter
client_paramsOptional[Dict[str, Any]]NoneExtra 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.