Prerequisites

The following examples require the requests library:
pip install -U requests
Set the following environment variables:
export AZURE_OPENAI_API_KEY="your-azure-openai-api-key"
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_API_VERSION="2023-12-01-preview"
export AZURE_OPENAI_IMAGE_DEPLOYMENT="your-dalle-deployment-name"

Example

The following agent can generate images using Azure OpenAI’s DALL-E:
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()],
)

agent.print_response("Generate an image of a sunset over mountains", stream=True)

Toolkit Params

ParameterTypeDefaultDescription
api_keyOptional[str]NoneAzure OpenAI API key. Uses AZURE_OPENAI_API_KEY if not set.
azure_endpointOptional[str]NoneAzure OpenAI endpoint. Uses AZURE_OPENAI_ENDPOINT if not set.
api_versionOptional[str]"2023-12-01-preview"Azure OpenAI API version.
image_deploymentOptional[str]NoneDALL-E deployment name. Uses AZURE_OPENAI_IMAGE_DEPLOYMENT.
image_modelstr"dall-e-3"DALL-E model to use (dall-e-2, dall-e-3).
image_qualityLiteral"standard"Image quality: “standard” or “hd” (hd only for dall-e-3).
enable_generate_imageboolTrueEnable the generate image functionality
allboolFalseEnable all functionality when set to True

Toolkit Functions

FunctionDescription
generate_imageGenerate images using Azure OpenAI DALL-E models.
You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.

Developer Resources