# 🤖 ChatBot AI with OpenAI (Node.js)
This is a lightweight Node.js-based chatbot API that connects to OpenAI's language models (like `text-davinci-003` or `gpt-4`) to generate AI-powered responses for any input prompt.
## 🚀 Features
- Chat completion using OpenAI's API
- Express.js backend server
- Handles CORS and JSON body parsing
- Secure API key via environment variables
- Clear error handling
- Simple POST endpoint (`/message`)
---
## 📦 Installation
1. **Clone the repository**
```bash
git clone https://github.com/your-username/chatbot-openai-node.git
cd chatbot-openai-node- Install dependencies
npm install- Create a
.envfile
OPENAI_API_KEY=your_openai_api_key
PORT=3000Start the server:
node index.jsOr with nodemon for development:
npx nodemon index.jsPOST /message
Content-Type: application/json
{
"prompt": "Tell me a fun fact about space"
}"Sure! Did you know that one day on Venus is longer than one year on Venus?"
⚠️ IMPORTANT: You must have a valid OpenAI account with billing enabled to use the API. Without this, your requests will be rejected by OpenAI.
Sign up and manage billing here: https://platform.openai.com/account/billing
text-davinci-003(completion)gpt-3.5-turbo/gpt-4(chat) (you'll need to change the model key if switching)
├── index.js # Express server with OpenAI API logic
├── .env # Your secret API keys
├── package.json # Node dependencies and scripts
MIT
Adeluola Ayomide David — @theStrategist