Building an Agent in 5 Minutes
Via the Foundry Portal
- Navigate to Agents in your project sidebar
- Click + New Agent
- Select a deployed model (e.g., gpt-4o)
- Write system instructions defining the agent's role
- Add tools (code interpreter, file search, custom functions)
- Test in the Agent Playground
Via the SDK (Python)
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
project = AIProjectClient(
endpoint="<endpoint>",
credential=DefaultAzureCredential()
)
agent = project.agents.create_agent(
model="gpt-4o",
name="Research Assistant",
instructions="You are a research assistant. Search the web and summarize findings clearly.",
tools=[{"type": "code_interpreter"}]
)
thread = project.agents.create_thread()
project.agents.create_message(
thread_id=thread.id,
role="user",
content="Analyze the latest trends in renewable energy"
)
run = project.agents.create_and_process_run(
thread_id=thread.id,
agent_id=agent.id
)
messages = project.agents.list_messages(thread_id=thread.id)
print(messages.data[0].content[0].text.value)
🎯 Pro Tip: Write agent instructions as if briefing a new employee. Be specific about what the agent should and should NOT do, what tone to use, and how to handle edge cases.