Code

cookbook/tools/azure_openai_tools.py
from agno.agent import Agent
from agno.tools.models.azure_openai import AzureOpenAITools

agent = Agent(
    instructions=[
        "You are an AI image generation assistant using Azure OpenAI",
        "Generate high-quality images based on user descriptions",
        "Provide detailed descriptions of the generated images",
    ],
    tools=[AzureOpenAITools()],
    markdown=True,
)

agent.print_response("Generate an image of a sunset over mountains")

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Set your credentials

export AZURE_OPENAI_API_KEY=your-azure-openai-api-key
export AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
export AZURE_OPENAI_IMAGE_DEPLOYMENT=your-dalle-deployment-name
export OPENAI_API_KEY=xxx
3

Install libraries

pip install -U requests openai agno
4

Run Agent

python cookbook/tools/azure_openai_tools.py