You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# GPT Bot - Protected API Version
This is a GPT Bot application with a **protected API** setup. The API key is now stored securely on the server side using environment variables, rather than being exposed in the frontend code.
## Security Improvements
- **API Key Protection**: The OpenRouter API key is stored in a `.env` file on the server, not in the frontend JavaScript
- **Backend Proxy**: All API requests go through a backend server that handles the API key securely
- **No Exposed Credentials**: The client-side code no longer contains any API keys
## Prerequisites
- Node.js (version 14 or higher)
- npm or yarn
## Installation
1. **Install dependencies**:
```bash
npm install
```
2. **Configure API Key**:
- The `.env` file has already been created with the API key
- If you need to update the API key, edit the `.env` file:
```
OPENROUTER_API_KEY=your-api-key-here
```
## Running the Application
1. **Start the backend server**:
```bash
npm start
```
2. **Open the application**:
- Open `index.html` in your browser
- Or serve it using a local server (e.g., `npx serve` or VS Code Live Server)
3. **The server runs on**:
- Backend: http://localhost:3000
- Frontend: http://localhost:3000 (when serving the static files)
## How It Works
1. **Frontend** (script.js): Sends requests to the local backend (`/api/chat` and `/api/image`)
2. **Backend** (server.js): Receives requests, adds the API key from environment variables, and forwards them to OpenRouter
3. **Environment Variables**: The API key is stored in `.env` and loaded by the backend server
## File Structure
```
.
├── index.html # Main HTML file
├── script.js # Frontend JavaScript (no API key!)
├── style.css # Styles
├── server.js # Backend server
├── package.json # Node.js dependencies
├── .env # Environment variables (API key) - NOT committed to git
├── .gitignore # Git ignore rules
└── README.md # This file
```
## Important Security Notes
- **Never commit the `.env` file** to version control! It's already in `.gitignore`
- The API key is now protected on the server side
- Users cannot view or steal the API key from the browser
# ChatBot
# Chat-Bot