How to build your own Agentic AI system using Crewai

AI?
Agentic AI, originally introduced by Andrew ng as AI are autonomous “partners”. organize, perform complex tasksIs the new concept emerging from the explosion of generative ai applications. This term has gained popularity rapidly since the end of July 2025, according to its search volume on Google Trends.
Despite recent developments, a research article from BCG “Agentic AI is transforming business platforms” shows that organizations have enthusiastically adopted agentic auton platforms, which facilitate the flow of 20% to 30% to 30% to 30% to 30% to 30% faster workflow cycles.
From LLMS to many Agent programs
What distinguishes an Agentic AI system from traditional automation systems is its independence in planning actions and logical, long-term goals such as achieving a specific, pre-defined goal. Because of this, there are strong difficulties or fixed tractives that are set for decisions that end the steps between the agents. “Associative Thinking and Acting with Linguistic Models” is considered as the foundational paper that forms the framework of the first LLM agent “reaction”, which includes three main elements – action, thoughts and what you saw. If you are interested in more details on how it works, please see my blog post “6 common LLM techniques briefly explained”.
With the rapid growth of this field, it is becoming clear that a single LLM agent cannot cope with the high demand for AI applications and integration. Therefore, multi-agent systems are developed to work with agent-to-agent functionality in dynamic workflows. While each agent is task-based, task-oriented, and focused on achieving a single goal, a multi-tasking system is multi-functional and general in its capabilities. Langchain Title “Many buildings of many buildings“It has shown that when the number of databases is required to increase the workload, the performance of a single system deteriorates while a multi-agent system can achieve stable performance by reducing the number of servings of each agent.
Build a simple AI Agent program using crewai
Crewai is an open source Python framework that allows developers to build production-ready teams and AI agent teams to tackle complex tasks. Compared to other popular pharmaceutical frameworks such as Langchain and Llamaindex, it focuses more on role-based collaboration, while offering less flexibility in complex aventic architecture. Although it is a relatively small frame, increasing availability is expected from July 2025 due to ease of use.
We can use the analogy of hiring a working project team (or a crew) When using the Crewai framework to create an agentic system, each AI Agent In Crew there is a specific role that can be compatible and related to many Activities. Agents equipped with Tools that makes them finish the jobs.
Now that we've covered the main concepts of the Crewail framework Framework, task, tool, and team – let's take a look at some sample code to build a small working agentic system.
1 Install Crewai and set environment variables using the bash commands below, e.g
pip install crewai
pip install 'crewai[tools]'
export OPENAI_API_KEY='your-key-here'
2. Create tools from the list of tools built-in-Creway, e.g. Claim DirectoryReadTool() Access directory, too FileReadTool() reading files stored in the directory.
from crewai_tools import DirectoryReadTool, FileReadTool
doc_tool = DirectoryReadTool(directory='./articles')
file_tool = FileReadTool()
3. Activate the agent by defining its role, mission, and providing it with tools.
from crewai import Agent
researcher = Agent(
role="Researcher",
goal="Find information on any topic based on the provided files",
tools=[doc_tool, file_tool]
)
4. Create a job by giving a description and assigning an agent to do the job.
from crewai import Task
research_task = Task(
description="Research the latest AI trends",
agent=researcher
)
5. Create a group that brings your agents and activities together. Start the workflow using kickoff().
from crewai import Crew
crew = Crew(
agents=[researcher],
tasks=[research_task]
)
result = crew.kickoff()
Develop a social media marketing team
0. Project objectives
Let's build on this simple Creway example by creating a social media group with the step-by-step process below. This team will generate blog posts based on the user's job title and create corresponding campaign messages to share on various Social Media platforms.

An example of output if we ask for the “Agentic AI” topic group.
Blog post

X (twitter) messageDiscover the Future of Agentic AI! Have you ever wondered how Agentic AI is set to redefine our interaction with technology by 2025? Understanding AI trends for 2025 is not only crucial for technology enthusiasts but essential for businesses across various sectors. #AgenticAI #AITrends
YouTube messageExplore Groundbreaking Trends in Agentic AI! 🌟 Uncover how Agentic AI is transforming industries in ways you never imagined! By 2025, these revolutionary trends will reshape how we engage with technologies, particularly in banking and finance. Are you ready to embrace the future? Don't forget to read our latest blog post and subscribe for more insights!
Import messageThe Changing Landscape of Agentic AI: What You Need to Know In 2025, the evolving world of Agentic AI is set to reshape industries, particularly in finance and banking. This blog covers key trends such as the transformational potential of agentic AI, new regulatory frameworks, and significant technological advancements. How can businesses successfully integrate agentic AI while managing risks? What does the future of this technology mean for consumers? Join the dialogue in our latest post, and let's explore how these innovations will impact our future together!
1. Project Environment Setup
Follow Creway's Quickstart guide to set up the development environment. We use the following directory structure for this project.
├── README.md
├── pyproject.toml
├── requirements.txt
├── src
│ └── social_media_agent
│ ├── __init__.py
│ ├── crew.py
│ ├── main.py
│ └── tools
│ ├── __init__.py
│ ├── browser_tools.py
│ └── keyword_tool.py
└── uv.lock
2. Developing tools
It's the first tool we include in the group WebsiteSearchToolWhich is a built-in tool created by Crewai for running semantic searches within the content of websites.
We just need a few lines of code to install the Crewai tools package and use it WebsiteSearchTool. This tool is available to the market researcher agent to find the latest market trends or industry news related to the given topic.
pip install 'crewai[tools]'
from crewai_tools import WebsiteSearchTool
web_search_tool = WebsiteSearchTool()
The screenshot below shows the output of the web_search_tool If you are given the title “YouTube videos”.

Next, we will create a custom keyword_tool By inheriting from baset class and using serpapi (Google Trend API). As shown in the code below, this tool generates high demand, trending queries related to the input keyword. This tool is available for professional marketing agent to search keywords and refine Blog Post for better engine performance. We'll see an example of key tool output in the next section.
import os
import json
from dotenv import load_dotenv
from crewai.tools import BaseTool
from serpapi.google_search import GoogleSearch
load_dotenv()
api_key = os.getenv('SERPAPI_API_KEY')
class KeywordTool(BaseTool):
name: str = "Trending Keyword Tool"
description: str = "Get search volume of related trending keywords."
def _run(self, keyword: str) -> str:
params = {
'engine': 'google_trends',
'q': keyword,
'data_type': 'RELATED_QUERIES',
'api_key': api_key
}
search = GoogleSearch(params)
try:
rising_kws = search.get_dict()['related_queries']['rising']
top_kws = search.get_dict()['related_queries']['top']
return f"""
Rising keywords: {rising_kws} n
Top keywords: {top_kws}
"""
except Exception as e:
return f"An unexpected error occurred: {str(e)}"
3. Define labor class

In the .Spy.Spy article, we describe our three-person social media team-Market_Rereaseonder, Content_kretor, marketing_specialist– Those who provide individual tasks. We start the SocialMediaCrew() Class you use @CrewBase an ornament. This page topic Crossover passes the user's input with their parentage title, too llm , model_name Attributes specify the default model used throughout Crew Workflow.
@CrewBase
class SocialMediaCrew():
def __init__(self, topic: str):
"""
Initialize the SocialMediaCrew with a specific topic.
Args:
topic (str): The main topic or subject for social media content generation
"""
self.topic = topic
self.model_name = 'openai/gpt-4o'
self.llm = LLM(model=self.model_name,temperature=0)
4. Define agents
Crewai Agents rely on three key parameters-role, mission, and backstory– To explain their characteristics and the context in which they work. In addition, we provide relevant agents tools To simplify their tasks and other parameters to control the use of resources for the agent's call and to avoid the unnecessary use of the LLM Token.
For example, we define a “Marting Specialist agent” using the code below. Start by using @agent an ornament. Define the role as “sales specialist” and provide access keyword_tool In the past, we have expanded in the past, so that marketing experts can research keywords to enrich blog content with SEO efficiency.
Visit our GitHub site for complete code for other agent definitions.
@CrewBase
class SocialMediaCrew():
def __init__(self, topic: str):
"""
Initialize the SocialMediaCrew with a specific topic.
Args:
topic (str): The main topic or subject for social media content generation
"""
self.topic = topic
self.model_name = 'openai/gpt-4o'
self.llm = LLM(model=self.model_name,temperature=0)
Set up verbose In fact it allows us to use Crewway's Traceability function to check the output of the middle of every call of the agent. The screenshots below show the thought process a “Marketing Specialist” useskeyword_tool Researching “YouTube Trends”, and SEO-DEVELOPED BLOG based on tool exposure.
Outbound sales professionals


Another way to define an agent is to store the agent context in a yaml file using the format below, which provides more flexibility for testing and rapid engineering where necessary.
For example agent.yaml
marketing_specialist:
role: >
"Marketing Specialist"
goal: >
"Improve the blog post to optimize for Search Engine Optimization using the Keyword Tool and create customized, channel-specific messages for social media distributions"
backstory: >
"A skilled Marketing Specialist with expertise in SEO and social media campaign design"
5. Define activities
If the agent is considered as an employee (“WHO”) specialized in the domain (eg. Content creation, research), combined with actions (“what” defined expectations.
In Crewai, work is organized using description, expected_outputand optional parameter output_file Saves the intermediate result as a file. Alternatively, it is also recommended that you use a standalone yaml file to provide a clean, maintainable way to define functions. In the Code Snippet below, we provide specific instructions for the Crew to perform the four tasks and provide the agents with the appropriate skills. We also store the output of each job in a working folder to make it easier to compare different types of output.
research: research on the market trend of a given topic; provided by a market researcher.write: Write engaging blog posts; provided by the Content Creator.refine: Analyze Blog Blog based on SEO efficiency; provided by a marketing professional.distribute: generate special messages for the platform to distribute on each social media channel; provided by a marketing professional.
@task
def research(self) -> Task:
return Task(
description=f'Research the 2025 trends in the {self.topic} area and provide a summary.',
expected_output=f'A summary of the top 3 trending news in {self.topic} with a unique perspective on their significance.',
agent=self.market_researcher()
)
@task
def write(self) -> Task:
return Task(
description=f"Write an engaging blog post about the {self.topic}, based on the research analyst's summary.",
expected_output='A 4-paragraph blog post formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon.',
agent=self.content_creator(),
output_file=f'blog-posts/post-{self.model_name}-{timestamp}.md'
)
@task
def refine(self) -> Task:
return Task(
description="""
Refine the given article draft to be highly SEO optimized for trending keywords.
Include the keywords naturally throughout the text (especially in headings and early paragraphs)
Make the content easy for both search engines and users to understand.
""",
expected_output='A refined 4-paragraph blog post formatted in markdown with engaging and SEO-optimized contents.',
agent=self.marketing_specialist(),
output_file=f'blog-posts/seo_post-{self.model_name}-{timestamp}.md'
)
@task
def distribute(self) -> Task:
return Task(
description="""
Generate three distinct versions of the original blog post description, each tailored for a specific distribution channel:
One version for X (formerly Twitter) – concise, engaging, and hashtag-optimized.
One version for YouTube post – suitable for video audience, includes emotive cue and strong call-to-action.
One version for Substack – slightly longer, informative, focused on newsletter subscribers.
Each description must be optimized for the norms and expectations of the channel, making subtle adjustments to language, length, and formatting.
Output should be in markdown format, with each version separated by a clear divider (---).
Use a short, impactful headline for each version to further increase channel fit.
""",
expected_output='3 versions of descriptions of the original blog post optimized for distribution channel, formatted in markdown, separated by dividers.',
agent=self.marketing_specialist(),
output_file=f'blog-posts/social_media_post-{self.model_name}-{timestamp}.md'
)
The Crewai Output Log below shows job execution details, including status, agent assignments and tool usage.
🚀 Crew: crew
├── 📋 Task: research (ID: 19968f28-0af7-4e9e-b91f-7a12f87659fe)
│ Assigned to: Market Research Analyst
│ Status: ✅ Completed
│ └── 🔧 Used Search in a specific website (1)
├── 📋 Task: write (ID: 4a5de75f-682e-46eb-960f-43635caa7481)
│ Assigned to: Content Writer
│ Status: ✅ Completed
├── 📋 Task: refine (ID: fc9fe4f8-7dbb-430d-a9fd-a7f32999b861)
│ **Assigned to: Marketing Specialist**
│ Status: ✅ Completed
│ └── 🔧 Used Trending Keyword Tool (1)
└── 📋 Task: distribute (ID: ed69676a-a6f7-4253-9a2e-7f946bd12fa8)
**Assigned to: Marketing Specialist**
Status: ✅ Completed
└── 🔧 Used Trending Keyword Tool (2)
╭───────────────────────────────────────── Task Completion ──────────────────────────────────────────╮
│ │
│ Task Completed │
│ Name: distribute │
│ Agent: Marketing Specialist │
│ Tool Args: │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
6. Cut back on staff
As the last step in the Crew.Spy script, we run jobs, agents and tools together to define workers.
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents,
tasks=self.tasks,
verbose=True,
planning=True,
)
In main.py, we immediately a SocialMediaCrew() object and run the workers by accepting user input with their parent title.
# main.py
from social_media_agent.crew import SocialMediaCrew
def run():
# Replace with your inputs, it will automatically interpolate any tasks and agents information
inputs = {
'topic': input('Enter your interested topic: '),
}
SocialMediaCrew(topic=inputs['topic']).crew().kickoff(inputs=inputs)
Now let's use “agentic ai” as an example and here are the output files generated by Social Media Crew after extracting the jobs.
Output from task “Write”

Output from the “analysis” function

The output from the “distribute” function

That-Home message
This tutorial shows how to build an Agentic AI system using the Crewai framework. By recruiting specialized agents with different roles and different tools, we use a multi-talented agent team that can produce well-made content for different social media platforms.
- Environment Setup: Start your development environment with the necessary dependencies and tools for Crewai development
- Developing tools: Improving the basic tool structure with built-in and custom tool elements
- Define agents: Create special agents with clearly defined roles, objectives, and backgrounds. Equip them with the right tools to support their role.
- Create Jobs: Create tasks with clear definitions and expected outcomes. Assign agents to the execution of tasks.
- Kick off the Crew: Orchestrate tasks, agents and tools together as a team and deliver workflows.



