Microsoft Agent Framework Foundry
raw JSON → 1.3.0 verified Sat May 09 auth: no python
Microsoft Foundry integrations for the Microsoft Agent Framework. Version 1.3.0 supports Python >=3.10. This library provides bindings and utilities to deploy, trace, and manage agents using Azure AI Foundry (formerly Azure AI Studio).
pip install agent-framework-foundry Common errors
error ModuleNotFoundError: No module named 'agent_framework' ↓
cause Trying to import the library with hyphens or as 'agent-framework-foundry' directly.
fix
Use 'from agent_framework_foundry import ...' with underscores.
error TypeError: AgentFrameworkClient.__init__() got an unexpected keyword argument 'api_key' ↓
cause Some versions expect 'credential' parameter instead of 'api_key'. The library uses Azure authentication by default.
fix
Use 'credential' or set environment variables. For API key, use 'from agent_framework_foundry.auth import ApiKeyCredential' and pass 'credential=ApiKeyCredential(api_key)'.
error AttributeError: 'FoundryAgent' object has no attribute 'run' ↓
cause The 'run' method is on the client, not on the agent object.
fix
Call 'client.run(agent=agent, input=...)' instead of 'agent.run(...)'.
Warnings
breaking In version 1.0.0, the 'run' method signature changed: the 'input' parameter is now the second positional argument instead of a keyword-only argument. Update calls to 'client.run(agent, input=...) to 'client.run(agent, input=...)' only if using positional; keyword still works. ↓
fix Ensure you pass 'input' as a keyword argument or second positional arg.
gotcha The 'tools' parameter in FoundryAgent expects a list of tool definitions, not function references. Many users mistakenly pass Python functions. You must wrap functions with a Tool schema. ↓
fix Use the provided 'Tool' type from 'agent_framework_foundry.models' to define tools.
deprecated The 'AgentFrameworkClient' class constructor parameter 'base_url' is deprecated in 1.3.0; use 'endpoint' instead. 'base_url' will be removed in 2.0.0. ↓
fix Replace 'base_url' with 'endpoint'.
Imports
- FoundryAgent wrong
from agent_framework import FoundryAgentcorrectfrom agent_framework_foundry import FoundryAgent - AgentFrameworkClient wrong
from agent_framework import Clientcorrectfrom agent_framework_foundry.client import AgentFrameworkClient
Quickstart
import os
from agent_framework_foundry import FoundryAgent
from agent_framework_foundry.client import AgentFrameworkClient
# Use environment variable for authentication
api_key = os.environ.get('FOUNDRY_API_KEY', '')
client = AgentFrameworkClient(api_key=api_key)
agent = FoundryAgent(
name="my-agent",
instructions="You are a helpful assistant.",
tools=[]
)
response = client.run(agent=agent, input="Hello, world!")
print(response)