AI Foundry Tool Use
Use WebSearchTools with a current Foundry deployment that supports function calling.
This source uses Agno's classic AzureAIFoundry adapter and the azure-ai-inference package, which Microsoft retired on August 26, 2026. Existing endpoint availability is separate from SDK retirement. For a new integration, use the current Foundry API setup with a compatible deployment. The classic setup below applies only to an existing compatible endpoint unless a current adaptation is explicitly provided.
Microsoft retired Cohere-command-r-08-2024 on May 12, 2026. Keep the source for reference and apply the current adapter/deployment changes in the run steps. The deployment must support tool calling for this example. Choose a model available in your resource; changing a string does not create a deployment. See the Azure retirement schedule.
"""Run `uv pip install ddgs` to install dependencies."""
import asyncio
from agno.agent import Agent
from agno.models.azure import AzureAIFoundry
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=AzureAIFoundry(id="Cohere-command-r-08-2024"),
tools=[WebSearchTools()],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync + Streaming ---
agent.print_response("What is currently happening in France?", stream=True)
# --- Async ---
asyncio.run(agent.aprint_response("Whats happening in France?"))Run the Current Adaptation
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai ddgsUse a current Foundry deployment
Deploy an available model supporting Chat Completions and the capabilities used by this example. Copy its exact deployment name, the resource's OpenAI-compatible URL ending in /openai/v1, and its key. See the current Foundry API setup.
export FOUNDRY_DEPLOYMENT="your_deployment_name"
export FOUNDRY_BASE_URL="https://your-resource.services.ai.azure.com/openai/v1"
export FOUNDRY_API_KEY="your_resource_key"In the saved source, replace the AzureAIFoundry import with:
from os import environ
from agno.models.openai.like import OpenAILikeReplace the entire AzureAIFoundry(...) expression with:
OpenAILike(
id=environ["FOUNDRY_DEPLOYMENT"],
api_key=environ["FOUNDRY_API_KEY"],
base_url=environ["FOUNDRY_BASE_URL"],
)Keep the surrounding Agent arguments and run calls. The deployment name can differ from the catalog's model name; it must match the deployment at this endpoint.
Run the example
Apply the current model import and constructor replacements above. Save the adapted code as tool_use.py, then run:
python tool_use.pyFull source: cookbook/90_models/azure/ai_foundry/tool_use.py