# Build Deep Research AI Agent with Next.js, Vercel AI SDk and LLMs like Gemini, Deepseek & Gpt-4o

> Learn how to build a powerful Deep Research AI agent like Gemini or ChatGPT using Next.js, Vercel AI SDK, and Exa Search API. Create an intelligent system that generates follow-up questions, crafts optimal search queries, and compiles comprehensive research reports.

- **Source:** DevDreaming (https://devdreaming.com)
- **Canonical URL:** https://devdreaming.com/videos/deep-research-ai-agent-nextjs-aisdk-exasearch
- **Author:** CodeBucks
- **Published:** 2025-03-19
- **Last updated:** 2025-04-06
- **Topics:** Next.js, AI, AI Agents

---

**[▶ Watch on YouTube](https://www.youtube.com/watch?v=zKN18GQBxCM)**

### Overview

In this tutorial, you'll learn how to build a powerful [Deep Research AI Agent](/videos/category/ai-agents) that rivals top AI systems like Gemini or ChatGPT. By leveraging [Next.js](/videos/category/next-js), **Vercel AI SDK**, and **Exa Search API**, you will create an intelligent system capable of generating follow-up questions, crafting optimal search queries, and compiling comprehensive research reports.

Learn how to integrate multiple Large Language Models (LLMs), such as Gemini and deepseek, through OpenRouter to generate follow-up questions and dynamic search queries. Use the [token counter](/tools/token-counter-visualizer) and [LLM pricing calculator](/tools/llm-api-pricing-calculator) to estimate the context and cost of that research loop. You'll see how to retrieve highly relevant search results from Exa Search and use these insights to refine and improve your research loop.

### What You'll Learn

- **Project Setup:** How to set up a Next.js project integrated with the Vercel AI SDK.
- **AI Agents vs. AI Workflows:** Understand the difference and benefits of each approach.
- **LLM Integration:** Connect multiple Large Language Models (LLMs) like Gemini and DeepSeek through OpenRouter.
- **Dynamic Research Workflow:** Implement an iterative research loop with dynamic query generation.
- **Search Optimization:** Integrate the Exa Search API for highly relevant search results.
- **Content Extraction:** Build a system for content extraction and relevance filtering.
- **Comprehensive Reporting:** Create a full research loop that compiles detailed research reports.

### 🚀 Key Features

- 🔧 Fully Customizable Research Flow
- 🔍 Adaptive Search Queries
- ⚙ Seamless LLM Integration
- 💼 Modular Components
- 🌐 Next.js & Vercel AI SDK
- ♻ Iterative Research Loop

### 🛠 Tech Stack

- **Framework:** Next.js 15 (App Router)
- **Styling:** Tailwind CSS, Shadcn UI
- **AI Integration:** Vercel AI SDK
- **LLMs:** GPT-4o, Gemini, Deepseel using OpenRouter
- **Web Search:** Exa Search API
- **UI Components:** Shadcn
- **Language:** TypeScript

### Code Links

- Final Source Code: [Link](https://github.com/codebucks27/Deep-Research-AI-Agent)

### ⚡ Prerequisites

Before you begin, ensure you have:

- OpenRouter API key (or you can use grok or any other LLM providers)
- Exa search API key

### Timestamps

- Intro [@00:00:00](https://www.youtube.com/watch?v=zKN18GQBxCM&t=0s)
- What is an AI Agent? [@00:03:40](https://www.youtube.com/watch?v=zKN18GQBxCM&t=220s)
- AI Agent Driven Workflow (logic) [@00:06:08](https://www.youtube.com/watch?v=zKN18GQBxCM&t=368s)
- Setup & Installation [@00:10:15](https://www.youtube.com/watch?v=zKN18GQBxCM&t=615s)
- Creating Layout [@00:14:20](https://www.youtube.com/watch?v=zKN18GQBxCM&t=860s)
- User Input Component [@00:19:20](https://www.youtube.com/watch?v=zKN18GQBxCM&t=1160s)
- Generate Questions using AI [@00:24:35](https://www.youtube.com/watch?v=zKN18GQBxCM&t=1475s)
- Implement Deep Research Route [@01:12:22](https://www.youtube.com/watch?v=zKN18GQBxCM&t=4342s)
- Exa Search API Implementation [@01:43:12](https://www.youtube.com/watch?v=zKN18GQBxCM&t=6182s)
- Extracting Data from Search Results [@01:57:40](https://www.youtube.com/watch?v=zKN18GQBxCM&t=6460s)
- Analyze Search Results using LLM [@02:09:37](https://www.youtube.com/watch?v=zKN18GQBxCM&t=7777s)
- Generate Comprehensive Report from Findings [@02:27:55](https://www.youtube.com/watch?v=zKN18GQBxCM&t=8875s)
- Show Activities and Sources [@02:56:55](https://www.youtube.com/watch?v=zKN18GQBxCM&t=10715s)
- Download Report in Markdown Format [@03:33:30](https://www.youtube.com/watch?v=zKN18GQBxCM&t=12710s)
- Create Research Timer [@03:38:10](https://www.youtube.com/watch?v=zKN18GQBxCM&t=13090s)
- Error Handling for AI Agent [@03:44:10](https://www.youtube.com/watch?v=zKN18GQBxCM&t=13450s)
- Build Component to Show Question-Answers [@04:05:30](https://www.youtube.com/watch?v=zKN18GQBxCM&t=14730s)

---

## Related on DevDreaming

- [All Video Tutorials](https://devdreaming.com/videos)
- [Blog & Tutorials](https://devdreaming.com/blogs)
- [Free Developer Tools](https://devdreaming.com/tools)

---

_This is the Markdown twin of a page on **DevDreaming** -- free developer tutorials, tools, and AI resources. Source of truth: the canonical HTML URL above._