Back to Agno

Azure OpenAI Cookbook

cookbook/90_models/azure/openai/README.md

2.6.51.4 KB
Original Source

Azure OpenAI Cookbook

Note: Fork and clone this repository if needed

1. Create and activate a virtual environment

shell
python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate

2. Export environment variables

Navigate to the AzureOpenAI on the Azure Portal and create a service. Then, using the Azure AI Foundry portal, create a deployment and set your environment variables.

shell
export AZURE_OPENAI_API_KEY=***
export AZURE_OPENAI_ENDPOINT="https://<your-resource-name>.openai.azure.com/openai/deployments/<your-deployment-name>"
export AZURE_API_VERSION="2024-10-21"  # Optional
export AZURE_DEPLOYMENT=***  # Optional

3. Install libraries

shell
uv pip install -U openai ddgs duckdb yfinance agno

4. Run basic Agent

  • Streaming on
shell
python cookbook/92_models/azure/openai/basic_stream.py
  • Streaming off
shell
python cookbook/92_models/azure/openai/basic.py

5. Run Agent with Tools

  • DuckDuckGo Search
shell
python cookbook/92_models/azure/openai/tool_use.py

6. Run Agent that returns structured output

shell
python cookbook/92_models/azure/openai/structured_output.py

7. Run Agent that uses storage

shell
python cookbook/92_models/azure/openai/storage.py

8. Run Agent that uses knowledge

shell
python cookbook/92_models/azure/openai/knowledge.py