frameworks/motia/docs/content/docs/examples/ai-deep-research-agent.mdx
Try it yourself:
View the source code for each step in the GitHub repository.
Clone the repository:
git clone https://github.com/MotiaDev/motia-examples
cd examples/ai-agents/specialized-agents/ai-deep-research-agent
Install dependencies:
pnpm install
# or
npm install
Configure environment variables:
cp .env.example .env
Update .env with your API keys:
# Required
OPENAI_API_KEY=your-openai-api-key-here
FIRECRAWL_API_KEY=your-firecrawl-api-key-here
# Optional
# OPENAI_MODEL=gpt-4o
# FIRECRAWL_BASE_URL=http://your-firecrawl-instance-url
POST /research
Content-Type: application/json
{
"query": "The research topic or question",
"breadth": 4, // Number of search queries to generate (1-10)
"depth": 2 // Depth of research iterations (1-5)
}
Response:
{
"message": "Research process started",
"requestId": "unique-trace-id"
}
GET /research/status?requestId=unique-trace-id
Response:
{
"message": "Research status retrieved successfully",
"requestId": "unique-trace-id",
"originalQuery": "The research topic or question",
"status": "in-progress",
"progress": {
"currentDepth": 1,
"totalDepth": 2,
"percentComplete": 50
},
"reportAvailable": false
}
GET /research/report?requestId=unique-trace-id
Response:
{
"message": "Research report retrieved successfully",
"report": {
"title": "Research Report Title",
"overview": "Executive summary...",
"sections": [
{
"title": "Section Title",
"content": "Section content..."
}
],
"keyTakeaways": [
"Key takeaway 1",
"Key takeaway 2"
],
"sources": [
{
"title": "Source Title",
"url": "Source URL"
}
],
"originalQuery": "The research topic or question",
"metadata": {
"depthUsed": 2,
"completedAt": "2025-03-18T16:45:30Z"
}
},
"requestId": "unique-trace-id"
}
Start the development server:
pnpm dev
Make a test request:
curl --request POST \
--url http://localhost:3111/research \
--header 'Content-Type: application/json' \
--data '{
"query": "Advancements in renewable energy storage",
"depth": 1,
"breadth": 1
}'