node-ai-chatbot-cli
Version:
A lightweight Node.js package and CLI tool that allows developers to easily interact with OpenAI's ChatGPT API. Supports automated API key setup, simple chatbot creation, and seamless integration into JavaScript applications. Ideal for building AI-powered
16 lines (12 loc) ⢠461 B
JavaScript
const fs = require('fs');
const path = require('path');
const prompt = require('prompt-sync')();
console.log("\nš§ ChatGPT Chatbot Setup");
const apiKey = prompt("Enter your OpenAI API Key: ");
if (!apiKey) {
console.error("ā API Key is required!");
process.exit(1);
}
fs.writeFileSync(path.join(__dirname, '.env'), `OPENAI_API_KEY=${apiKey}\n`);
console.log("ā
API Key saved! You can now use the chatbot.");