Azure Demo Cohere
Migrate a retired Azure Cohere recipe to a current Foundry Chat Completions deployment.
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. Choose a model available in your resource; changing a string does not create a deployment. See the Azure retirement schedule.
"""
Azure Demo Cohere
=================
Cookbook example for `azure/ai_foundry/demo_cohere.py`.
"""
from agno.agent import Agent, RunOutput # noqa
from agno.models.azure import AzureAIFoundry
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(model=AzureAIFoundry(id="Cohere-command-r-08-2024"), markdown=True)
# Get the response in a variable
# run: RunOutput = agent.run("Share a 2 sentence horror story")
# print(run.content)
# Print the response on the terminal
agent.print_response("Share a 2 sentence horror story")
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
passRun the Current Adaptation
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiUse 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 demo_cohere.py, then run:
python demo_cohere.pyFull source: cookbook/90_models/azure/ai_foundry/demo_cohere.py