An AI-powered interactive command-line interface that answers questions by combining real-time web search with advanced AI reasoning. Built with Genkit and Tavily APIs.
Learning Project: Developed as part of Big School's Master de desarrollo con IA program.
- 🔍 Real-time Web Search: Uses Tavily API to search current information from the web
- 🤖 AI-Powered Responses: Leverages Google's Gemini AI to synthesize search results into comprehensive answers
- 💬 Interactive CLI: User-friendly command-line interface with spinners and colored output
- 📚 Source Citations: Automatically includes URLs and sources in responses
- 💾 Chat History: Maintains conversation history during the session
- Node.js v18+
- API Keys:
- Google API Key for Gemini AI
- Tavily API Key for web search
-
Clone the repository
git clone <repository-url> cd 09-master-ia-cli-genkit
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Then edit
.envand add your API keys:TAVILY_API_KEY=your_tavily_key_here GOOGLE_API_KEY=your_google_api_key_here
npm startThis launches the interactive CLI where you can ask questions:
💬 Ask a question (or type "exit" to quit): What is the capital of France?
🧁 Thinking...
✅ Answer Received!
Answer:
The capital of France is Paris. Paris is the largest city in France and serves as the
political, cultural, and economic center of the country...
Sources:
[1] https://example.com/france-capital
[2] https://example.com/paris-info
npm run devThis also runs the interactive CLI and starts the Genkit Developer UI on http://localhost:4000 for development and debugging.
To access the UI:
- Click on the
http://localhost:4000link in the terminal, or - Open your browser and navigate to
http://localhost:4000
The Genkit UI allows you to:
- Test flows and prompts interactively
- View execution traces and AI model interactions
- Debug tool calls and API responses
- Monitor performance metrics
Interactive CLI in action - Ask questions and get AI-powered answers with web sources
09-master-ia-cli-genkit/
├── index.js # Main entry point - CLI setup and interaction loop
├── src/
│ ├── agent.js # Chat agent with search tool configuration
│ └── search.js # Tavily web search wrapper
├── .env.example # Environment variables template
└── README.md # This file
- User Input: User enters a question in the CLI
- Search: The chat agent uses Tavily's
searchWebtool to find current information - AI Processing: Google Gemini AI synthesizes search results with its knowledge
- Response: A comprehensive answer is formatted with citations and sources
- History: The exchange is stored in the chat session history
- index.js: Manages the CLI interface using Node.js
readlinemodule - agent.js: Defines the Genkit agent with the search tool and AI prompt
- search.js: Wraps the Tavily API with proper configuration options
| Technology | Purpose |
|---|---|
| Genkit | AI framework for building agentic apps |
| Google Gemini AI | Language model for reasoning |
| Tavily API | Real-time web search |
| Zod | TypeScript-first schema validation |
| Chalk | Terminal string styling |
| Ora | Elegant terminal spinners |
| dotenv | Environment variable management |
| Readline | CLI input/output (Node.js built-in) |
- @tavily/core - Tavily web search client
- Chalk - Terminal styling
- Ora - Progress spinners
- dotenv - Environment variables
- Zod - Schema validation
- Readline Module - Interactive CLI
This project was developed as part of the Master de Desarrollo con IA by Big School, a comprehensive program covering AI development with modern tools and frameworks.
Completion Date: February 9, 2026
- Use native Node.js fetch instead of Tavily package dependency
- Add conversation persistence (save/load chat history)
- Implement multi-turn context awareness
- Add support for different AI models
- Web dashboard interface alongside CLI