What is a crew in CrewAI
crew in CrewAI is a collaborative group of AI agents and human users that work together to automate complex workflows and tasks. It enables coordinated multi-agent interactions and shared task management within the CrewAI platform.Crew in CrewAI is a collaborative group of AI agents and humans that coordinate to automate workflows and solve tasks collectively.How it works
A crew in CrewAI functions like a team where multiple AI agents and human collaborators join forces to complete tasks. Each member of the crew has specific roles or capabilities, such as data processing, decision making, or user interaction. The crew orchestrates these members to work in parallel or sequence, enabling complex workflows that single agents cannot handle alone. Think of it as a project team where each member contributes their expertise to achieve a shared goal efficiently.
Concrete example
Here is a simplified example of creating and using a crew in CrewAI's Python SDK to automate a customer support workflow:
import os
from crewai import CrewAIClient
client = CrewAIClient(api_key=os.environ["CREWAI_API_KEY"])
# Define crew members with roles
crew_members = [
{"name": "agent_nlp", "role": "text_analysis"},
{"name": "agent_response", "role": "response_generation"},
{"name": "human_supervisor", "role": "approval"}
]
# Create a crew
crew = client.crews.create(name="support_team", members=crew_members)
# Assign a task to the crew
task = {
"input": "Customer complaint about delayed shipment.",
"workflow": ["agent_nlp", "agent_response", "human_supervisor"]
}
result = crew.run_task(task)
print(result) {'status': 'approved', 'response': 'We apologize for the delay and will expedite your shipment.'} When to use it
Use a crew in CrewAI when you need to coordinate multiple AI agents and humans to handle complex, multi-step workflows that require diverse skills or approvals. Crews are ideal for customer support automation, content moderation pipelines, or any scenario where tasks benefit from parallel processing and human oversight. Avoid using crews for simple single-agent tasks where a standalone AI model suffices.
Key terms
| Term | Definition |
|---|---|
| Crew | A group of AI agents and humans collaborating on tasks within CrewAI. |
| Agent | An individual AI model or component with a specific role in the crew. |
| Workflow | A defined sequence or parallel set of steps executed by crew members. |
| Task | A unit of work assigned to a crew for processing and completion. |
Key Takeaways
- A crew in CrewAI enables multi-agent and human collaboration for complex workflows.
- Use crews to automate tasks requiring diverse AI capabilities and human oversight.
- Crews orchestrate members through defined workflows for efficient task completion.