A feature-rich web-based chat interface that acts as a frontend for OpenAI-compatible APIs, with a comprehensive administrator panel for configuration management.
- Connects to any OpenAI-compatible API endpoint
- Supports streaming responses for real-time interaction
- Renders Markdown and LaTeX in chat messages
- Injects configurable system prompts (supports date placeholder
{{date}}) - "Copy" button for rich text message content
- "Copy Markdown" button for raw Markdown message content
- Optional logging of raw API responses
- Simple, clean interface
- Secure Admin Setup: Initial password setup with bcrypt hashing
- Session-based Authentication: Secure login/logout with express-session
- Multi-Profile Configuration: Create and manage multiple API configuration profiles
- Dynamic Profile Switching: Switch between different API providers without server restart
- Configuration Management: Web-based interface for managing API settings
- Password Management: Change admin password through the web interface
- Security Features: CSRF protection and secure session handling
-
Clone and Install:
git clone https://github.com/iXimNet/ChatWebUI.git cd ChatWebUI npm install -
Environment Setup:
cp .env.example .env # Edit .env file to set PORT and SESSION_SECRET -
Start the Server:
npm start # or for development: npm run dev -
Initial Admin Setup:
- Navigate to
http://localhost:3000(or your configured port) - You'll be redirected to the setup page to create an admin password
- Complete the setup and restart the server
- Navigate to
-
Configure API Profiles:
- Login at
http://localhost:3000/login.html - Access the admin panel at
http://localhost:3000/admin - Create and configure your API profiles
- Login at
The .env file contains minimal server configuration:
# Server port (optional, defaults to 3000)
PORT=3000
# Admin password hash (automatically set during setup)
ADMIN_PASSWORD_HASH=
# Session secret for secure sessions (required)
SESSION_SECRET=your_strong_session_secret_hereAPI configurations are managed through the admin panel and stored in config.json:
{
"profiles": {
"OpenAI": {
"API_BASE_URL": "https://api.openai.com/v1",
"API_KEY": "your_openai_api_key",
"MODEL_NAME": "gpt-4",
"API_SYSTEM_PROMPT": "You are a helpful assistant. Today's date is {{date}}.",
"API_LOG": false
},
"Custom Provider": {
"API_BASE_URL": "https://your-api-endpoint.com/v1",
"API_KEY": "your_api_key",
"MODEL_NAME": "custom-model",
"API_SYSTEM_PROMPT": "Custom system prompt here.",
"API_LOG": true
}
},
"activeProfile": "OpenAI"
}- Navigate to
http://localhost:PORT/login.html - Enter your admin password
- Access the admin dashboard at
http://localhost:PORT/admin
Create a New Profile:
- Click "Add New Profile" in the admin dashboard
- Fill in the configuration details:
- API_BASE_URL: The base URL of your API endpoint
- API_KEY: Your API key for authentication
- MODEL_NAME: The model to use (e.g., gpt-4, gpt-3.5-turbo)
- API_SYSTEM_PROMPT: System prompt (supports
{{date}}placeholder) - API_LOG: Enable/disable API response logging
Edit Existing Profiles:
- Click the "Edit" button next to any profile
- Modify settings and save changes
Switch Active Profile:
- Click "Activate" next to the profile you want to use
- Changes take effect immediately without server restart
Delete Profiles:
- Click "Delete" next to profiles you no longer need
- Active profiles cannot be deleted (switch to another first)
- Password Protection: All admin functions require authentication
- Session Management: Secure sessions with configurable timeouts
- CSRF Protection: Protection against cross-site request forgery
- Secure Cookies: HttpOnly, SameSite, and Secure cookie flags
GET /- Main chat interfacePOST /api/chat- Chat API proxy (uses active profile configuration)
GET /admin- Admin dashboardGET /admin/profiles- Get all profiles and active profilePOST /admin/profiles- Create new profilePUT /admin/profiles/:name- Update existing profileDELETE /admin/profiles/:name- Delete profilePOST /admin/profiles/:name/activate- Set profile as activePOST /admin/change-password- Change admin passwordPOST /admin/logout- Logout
GET /setup.html- Initial setup page (only when no admin password set)POST /admin/setup-password- Set initial admin password
ChatWebUI/
├── server.js # Main server file
├── package.json # Dependencies and scripts
├── .env # Environment configuration
├── .env.example # Environment template
├── config.json # API profiles (created automatically)
├── public/ # Static web files
│ ├── index.html # Main chat interface
│ ├── login.html # Admin login page
│ ├── admin.html # Admin dashboard
│ ├── setup.html # Initial setup page
│ ├── script.js # Chat interface logic
│ ├── login.js # Login page logic
│ ├── admin_dashboard.js # Admin panel logic
│ └── style.css # Styling
└── README.md # This file
npm run dev # Uses nodemon for auto-restart- express: Web server framework
- bcryptjs: Password hashing
- express-session: Session management
- csurf: CSRF protection
- cookie-parser: Cookie parsing middleware
- cors: Cross-origin resource sharing
- dotenv: Environment variable loading
- http-proxy-middleware: API proxying
- marked: Markdown rendering
- Strong Session Secret: Use a cryptographically strong session secret
- HTTPS in Production: Always use HTTPS in production environments
- Regular Password Updates: Change admin passwords regularly
- API Key Security: Store API keys securely and rotate them periodically
- Access Control: Limit access to the admin panel to authorized users only
Server won't start:
- Check if the port is already in use
- Verify
.envfile configuration - Ensure all dependencies are installed
Can't access admin panel:
- Complete the initial setup first
- Check if you're using the correct admin password
- Clear browser cookies and try again
API requests failing:
- Verify the active profile configuration
- Check API key validity
- Ensure the API endpoint is accessible
Type your message in the input box at the bottom and press Enter or click the Send button. The assistant's response will appear in the chat window. Use the copy buttons on assistant messages to copy the content.
This project is open source. Please check the repository for license details.
