Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Agency
✓ from agency_swarm import Agency
✗ from agency_swarm.agency import Agency
Agency is exported directly from the package, not a submodule.
Agent
✓ from agency_swarm import Agent
✗ from agency_swarm.agent import Agent
Agent is exported at the package level.
get_openai_client
✓ from agency_swarm.util import get_openai_client
Minimal example: create two agents, initialize Agency, run demo.
import os
from agency_swarm import Agent, Agency
# Ensure OpenAI API key is set
if not os.environ.get('OPENAI_API_KEY'):
print("Please set OPENAI_API_KEY environment variable.")
exit(1)
ceo = Agent(name="CEO",
description="Responsible for client communication and task delegation.",
instructions="You are a CEO agent. Delegate tasks to other agents.",
model="gpt-4")
assistant = Agent(name="Assistant",
description="Helps with tasks.",
instructions="You are an assistant.",
model="gpt-4")
agency = Agency([ceo, assistant],
shared_instructions="This is a shared instruction for all agents.")
if __name__ == '__main__':
agency.run_demo()
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'agency_swarm'
Package not installed or installed in wrong environment.
fixRun `pip install agency-swarm` in the correct virtual environment.
ImportError: cannot import name 'Agency' from 'agency_swarm'
Outdated version or incorrect import path.
fixUpgrade: `pip install --upgrade agency-swarm`. Use `from agency_swarm import Agency`.
ValueError: All agents must have unique names.
Duplicate agent names in the agency.
fixAssign unique `name` to each agent.
openai.error.AuthenticationError: Incorrect API key provided
Invalid or missing OpenAI API key.
fixSet the `OPENAI_API_KEY` environment variable or pass `api_key` to Agent constructor.
Upgrade
Version history
1.9.9latest on PyPI · released May 24, 2026
Audit
Dependencies
No dependency data recorded yet.