Building News AI Agents Using CrewAI And Google Gemini Pro LLM Models
Based on Krish Naik's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Create a Python 3.10 virtual environment and install dependencies from requirements.txt before building the CrewAI agents.
Briefing
The core takeaway is that a multi-agent workflow can generate a structured “news-style” report by chaining specialized agents—one that researches and one that writes—while using Google Gemini Pro (via LangChain) instead of OpenAI. The setup matters because CrewAI’s default examples assume an OpenAI API key, so swapping in Gemini Pro enables a practical, lower-friction path for building agentic applications with a non-OpenAI model.
The build starts from scratch: a Python 3.10 virtual environment is created, dependencies are installed from a requirements.txt, and environment variables are loaded with load_dotenv. Two model integrations are used: CrewAI for agent orchestration, and LangChain’s Google Gemini interface (chat Google generative AI) to connect the agents to Google’s Gemini Pro. The Gemini API key is obtained from Google AI Studio (AI studio.google.com/a/…/api key), then stored in an environment variable (the transcript references GOOGLE_API_KEY / “Google API key” loaded via os.getenv).
On the agent side, the workflow defines a “news researcher” agent and a “news writer” agent. The researcher’s role is to uncover “groundbreaking technologies” and produce a clear summary with market opportunities and risks; it’s configured with memory enabled and delegation allowed so it can coordinate tool use and handoffs. The writer agent is tasked with turning the research into an article: it’s instructed to compose an in-depth, industry-impact-focused piece formatted as Markdown.
A key enabling component is a search tool. The researcher agent is connected to a Google search capability implemented through SerpAPI-style tooling (the transcript uses “ser.dev” as a “world fastest and cheapest Google search API,” with an API key stored in the environment). This tool is imported into the CrewAI tool layer and then attached to the researcher so the agent can pull current information from the web, rather than relying solely on the model’s internal knowledge.
Tasks formalize the chain. A “research task” demands a comprehensive three-paragraph report on the latest AI trend, explicitly requesting pros, cons, narrative clarity, market opportunities, and potential risks. A “writer task” then requires a four-paragraph Markdown article that explains the trend and its impact on the industry. These tasks are bound to the corresponding agents.
Finally, the agents are assembled into a Crew with a sequential process: the researcher runs first, then the writer consumes the researcher’s output. Execution is kicked off with crew.kickoff using an input topic—example given: “AI in healthcare.” During execution, the researcher performs iterative web searches, compiles findings, and passes a synthesized result to the writer, which produces the final blog artifact (the transcript references an output file like new_blog_post.md). The run also surfaces a common integration issue—an import/initialization mismatch around the LangChain Gemini class—followed by a corrected workflow where the search tool successfully retrieves top titles and the agents complete the article generation.
Cornell Notes
CrewAI is used to orchestrate two cooperating agents—one that researches and one that writes—so they can produce a news-style article about a given topic. The system swaps out OpenAI for Google Gemini Pro by wiring LangChain’s Google Gemini chat model into the agents and loading the Gemini API key from environment variables. A web search tool (via ser.dev/SerpAPI-style integration) is attached to the researcher so it can gather current information, then pass a synthesized summary to the writer. Tasks specify output formats: a three-paragraph research report (including pros/cons, market opportunities, and risks) followed by a four-paragraph Markdown blog post. Running the crew in sequential mode ensures the writer waits for the researcher’s findings.
How does the build avoid OpenAI while still using CrewAI’s agent framework?
What roles do the two agents play, and how do they interact?
Why is a search tool essential in this workflow?
How do the tasks enforce the structure of the final output?
What does sequential execution change compared with other process modes?
What integration error appeared, and what does it illustrate?
Review Questions
- When swapping from OpenAI to Gemini in CrewAI, which components must be configured: the agent LLM, the API key loading, or the Crew process? Explain your reasoning.
- What exact elements are required in the research task output, and how do those requirements map to the writer task’s article structure?
- How does attaching the search tool to the researcher change the quality or reliability of the generated news-style report?
Key Points
- 1
Create a Python 3.10 virtual environment and install dependencies from requirements.txt before building the CrewAI agents.
- 2
Load Gemini and search API keys via environment variables using load_dotenv and os.getenv to keep secrets out of code.
- 3
Define two agents with distinct responsibilities: a news researcher (web-backed trend analysis) and a news writer (article generation).
- 4
Attach a web search tool (ser.dev/SerpAPI-style) to the researcher so it can gather current sources and synthesize pros/cons.
- 5
Use CrewAI tasks to enforce output structure: a three-paragraph research report followed by a four-paragraph Markdown blog post.
- 6
Run the crew with process.sequential so the writer waits for the researcher’s findings before drafting the final article.
- 7
Expect and debug integration issues around LangChain Gemini class imports/initialization; small naming mismatches can prevent the LLM from being created.