An interactive command-line chat tool that searches the web and generates AI-powered answers with sources, similar to Perplexity AI. Built with TypeScript, Node.js, Google Genkit (Gemini 3 Pro), and Tavily Search API.
- 🔍 Web search powered by Tavily API
- 🤖 AI-generated comprehensive answers using Google Genkit with Gemini 3 Pro
- 💬 Interactive chat mode with persistent conversation history
- 🛠️ AI agents with tool-calling capabilities
- 📚 Cited sources with URLs
- 🎨 Beautiful terminal output with colors and spinners
- ⚡ Fast and efficient
- Node.js 18 or higher
- TypeScript (installed as dev dependency)
- Tavily API key (get it from tavily.com)
- Google AI API key (get it from Google AI Studio)
- Clone the repository or navigate to the project folder:
cd project- Install dependencies:
npm install- Set up environment variables by creating a
.envfile:
touch .env- Add your API keys to the
.envfile:
TAVILY_API_KEY=your_tavily_api_key_here
GOOGLE_API_KEY=your_google_api_key_here
npm run devnpm startOr build and run separately:
npm run build
node dist/index.jsThis starts an interactive chat session where you can:
- Ask multiple questions in sequence
- Maintain conversation context across questions
- Type
exitorquitto leave - Press
Ctrl+Cto exit
💬 Ask a question (or type "exit" to quit): What is quantum computing?
✓ Response generated
[AI responds with detailed answer using web search results]
💬 Ask a question (or type "exit" to quit): How does it differ from classical computing?
✓ Response generated
[AI continues the conversation with context from previous question]
- Interactive Session: The CLI starts an interactive chat session with persistent conversation history
- Query Processing: When you ask a question, the AI agent analyzes if it needs current web information
- Tool Calling: If needed, the AI agent calls the web search tool using Tavily's API
- Search: Tavily searches the web for relevant, up-to-date information
- Generate: Google Genkit with Gemini 3 Pro analyzes the search results and conversation context to generate a comprehensive answer
- Display: The answer is displayed in the terminal with proper formatting
project/
├── index.ts # Main entry point with interactive chat interface
├── src/
│ ├── search.ts # Tavily search integration
│ └── agent.ts # Genkit AI agent with tool definitions
├── dist/ # Compiled JavaScript output (generated)
├── tsconfig.json # TypeScript configuration
├── package.json
├── .env # Environment variables (create this)
└── README.md
╔════════════════════════════════════════════════════╗
║ Welcome to Perplexity CLI - Interactive Mode ║
╚════════════════════════════════════════════════════╝
Type your questions and get AI-powered answers with sources!
Chat history is maintained during this session.
Commands: exit, quit, or press Ctrl+C to leave
💬 Ask a question (or type "exit" to quit): What is quantum computing?
✓ Response generated
Quantum computing is a revolutionary approach to computation that leverages
the principles of quantum mechanics. Unlike classical computers that use bits
(0s and 1s), quantum computers use quantum bits or "qubits" that can exist
in multiple states simultaneously...
[Sources and citations included in the response]
💬 Ask a question (or type "exit" to quit):
- Sign up at tavily.com
- Get your API key from the dashboard
- Free tier includes 1,000 searches per month
- Visit Google AI Studio
- Create a new API key
- Free tier available with rate limits
Error: TAVILY_API_KEY is not set
- Make sure you've created a
.envfile with your Tavily API key
Error: GOOGLE_API_KEY is not set
- Make sure you've added your Google AI API key to the
.envfile
Module not found errors
- Run
npm installto install all dependencies
TypeScript compilation errors
- Run
npm run buildto check for type errors - Check
tsconfig.jsonsettings if needed
- TypeScript - Typed superset of JavaScript
- Node.js - JavaScript runtime
- Google Genkit - AI framework for building AI-powered apps with tool-calling capabilities
- Gemini 3 Pro - Google's advanced AI model
- Tavily API - Web search API optimized for AI applications
- Chalk - Terminal styling
- Ora - Terminal spinners
- dotenv - Environment variable management
- Zod - Schema validation for tool definitions
- tsx - TypeScript execution for development
Apache License 2.0