Skip to content

davidadeluola/ChatBot-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# 🤖 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
  1. Install dependencies
npm install
  1. Create a .env file
OPENAI_API_KEY=your_openai_api_key
PORT=3000

💡 Usage

Start the server:

node index.js

Or with nodemon for development:

npx nodemon index.js

Make a request:

POST /message
Content-Type: application/json

{
  "prompt": "Tell me a fun fact about space"
}

Response:

"Sure! Did you know that one day on Venus is longer than one year on Venus?"

🔐 Billing Notice

⚠️ 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


🧠 Models Supported

  • text-davinci-003 (completion)
  • gpt-3.5-turbo / gpt-4 (chat) (you'll need to change the model key if switching)

📁 Project Structure

├── index.js          # Express server with OpenAI API logic
├── .env              # Your secret API keys
├── package.json      # Node dependencies and scripts

🔧 Dependencies


📜 License

MIT


✨ Author

Adeluola Ayomide David — @theStrategist


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors