Skip to main content

Overview

Microsoft Agent Framework is available for both Python and .NET. This guide covers installation, authentication setup, and environment configuration.

System Requirements

  • Python version: 3.10 or higher (supports 3.10, 3.11, 3.12, 3.13, 3.14)
  • Package manager: pip or uv
  • Operating systems: Windows, macOS, Linux

Install the framework

1

Install the core package

pip install agent-framework --pre
The --pre flag is required during the preview period.
2

Install optional provider packages (optional)

Install additional packages for specific providers:
# Azure AI integrations
pip install agent-framework-azure-ai --pre
pip install agent-framework-azure-ai-search --pre

# Other LLM providers
pip install agent-framework-anthropic --pre
pip install agent-framework-ollama --pre
pip install agent-framework-bedrock --pre

# Hosting and protocols
pip install agent-framework-azurefunctions --pre
pip install agent-framework-a2a --pre

# Memory and storage
pip install agent-framework-mem0 --pre
pip install agent-framework-redis --pre

# UI and development tools
pip install agent-framework-devui --pre
pip install agent-framework-chatkit --pre
3

Install all extensions (optional)

To install all available extensions:
pip install agent-framework[all] --pre
4

Verify installation

python -c "import agent_framework; print(agent_framework.__version__)"

Authentication setup

Microsoft Agent Framework uses Azure CLI credentials for authentication in development.
1

Install Azure CLI

Download and install from Azure CLI documentation:
winget install -e --id Microsoft.AzureCLI
2

Login to Azure

az login
This opens a browser window for authentication. After login, your credentials are cached locally.
3

Verify authentication

az account show
This displays your current Azure subscription details.
Production deployments: Use managed identities or service principals instead of Azure CLI credentials. See Azure authentication best practices.

Environment configuration

Required environment variables

Set these environment variables based on your provider:
# Azure AI Foundry project endpoint
export AZURE_AI_PROJECT_ENDPOINT="https://your-project-endpoint"

# Model deployment name (for Responses API)
export AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME="gpt-4o"

# Alternative: for Chat API
export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-4o"
Get your project endpoint from ai.azure.com → Your Project → Overview → Project connection string

Optional environment variables

export AZURE_SEARCH_ENDPOINT="https://your-search-service.search.windows.net"
export AZURE_SEARCH_API_KEY="your-api-key"
export AZURE_SEARCH_INDEX_NAME="your-index-name"
export AZURE_SEARCH_SEMANTIC_CONFIG="your-semantic-config"
export ANTHROPIC_API_KEY="sk-ant-..."
export ANTHROPIC_MODEL="claude-3-5-sonnet-20241022"
export OLLAMA_ENDPOINT="http://localhost:11434"
export OLLAMA_MODEL="llama2"
export ENABLE_INSTRUMENTATION=true
export ENABLE_SENSITIVE_DATA=true
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317/"
export MEM0_API_KEY="your-mem0-api-key"

Using .env files

For convenience, create a .env file in your project root:
Create .env:
# Azure AI
AZURE_AI_PROJECT_ENDPOINT="https://your-project-endpoint"
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME="gpt-4o"

# Optional: Azure AI Search
AZURE_SEARCH_ENDPOINT=""
AZURE_SEARCH_API_KEY=""
AZURE_SEARCH_INDEX_NAME=""
Load in your code:
from dotenv import load_dotenv

load_dotenv()  # Loads variables from .env
Never commit .env files with secrets to version control. Add .env to your .gitignore file.

Verify your installation

Test your setup with a minimal example:
# test_install.py
import asyncio
import os
from agent_framework.azure import AzureOpenAIResponsesClient
from azure.identity import AzureCliCredential
from dotenv import load_dotenv

load_dotenv()

async def test():
    credential = AzureCliCredential()
    client = AzureOpenAIResponsesClient(
        project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
        deployment_name=os.environ["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"],
        credential=credential,
    )
    
    agent = client.as_agent(
        name="TestAgent",
        instructions="You are a helpful assistant.",
    )
    
    result = await agent.run("Say hello!")
    print(f"✓ Agent Framework is working! Response: {result}")

if __name__ == "__main__":
    asyncio.run(test())
Run the test:
python test_install.py

Troubleshooting

Error: DefaultAzureCredential failed to retrieve a tokenSolution:
  1. Ensure you’ve run az login and authenticated successfully
  2. Check that your Azure account has access to the resources
  3. Verify your subscription is active: az account show
  4. Try clearing cached credentials: az account clear then az login again
Error: ModuleNotFoundError: No module named 'agent_framework'Solution:
  1. Verify installation: pip show agent-framework-core
  2. Check you’re using the correct Python environment
  3. Reinstall: pip install --force-reinstall agent-framework --pre
Error: Package 'Microsoft.Agents.AI.OpenAI' could not be foundSolution:
  1. Ensure you have access to the NuGet package source
  2. Clear NuGet cache: dotnet nuget locals all --clear
  3. Restore packages: dotnet restore
Error: Variables in .env not being readSolution:Python:
  • Ensure python-dotenv is installed: pip install python-dotenv
  • Add load_dotenv() before accessing environment variables
  • Check .env file is in the same directory as your script
NET:
  • Install DotNetEnv: dotnet add package DotNetEnv
  • Call DotNetEnv.Env.Load() at the start of your program
Error: Request timeout when calling Azure servicesSolution:
  1. Check your network connection and firewall settings
  2. Verify the endpoint URL is correct
  3. Ensure the Azure resource is running and accessible
  4. Check Azure service health: Azure Status

Next steps

Quickstart Guide

Build your first agent in 5 minutes

Core Concepts

Understand agents, tools, and sessions

Provider Configuration

Configure different LLM providers

Sample Code

Explore example projects
For additional help, visit the GitHub repository or join our Discord community.

Build docs developers (and LLMs) love