A Node.js application that generates fictional website content using AI models through the OpenRouter API. Requires an OpenRouter API key. Some models can be used free of charge.
- Dynamic website content generation using AI models
- Model selection from OpenRouter's available models
- Session-based configuration
- Custom prompt templates
- Automatic model validation and fallback
- Node.js: Version 14.0 or higher
- npm: Included with Node.js installation
- OpenRouter API Account: Required for AI model access
- Sign up at OpenRouter
- Obtain an API token
- You can use the free models without a credit card
- Clone the repository
- Install dependencies:
npm install
- Create a
.envfile with your configuration:OPENROUTER_TOKEN=your_openrouter_api_token SESSION_SECRET=your_session_secret PORT=3000
AI-Website/
├── app.js # Main application entry point
├── config/
│ └── config.js # Configuration settings
├── services/
│ ├── modelsService.js # Model management service
│ └── openRouterService.js # OpenRouter API service
├── routes/
│ └── index.js # Route handlers
├── middleware/
│ └── errorHandler.js # Error handling middleware
├── templates/
│ ├── index.html # Main template
│ └── models.json # Available models cache
└── package.json
npm run devnpm startVisit /reset to fetch and update the available models from OpenRouter.
Visit /the-page-where-it-starts to configure and start generating content.
Visiting any other URL without having configured a website redirects you here.
GET /the-page-where-it-starts- Main configuration pageGET /reset- Update available modelsGET /start- Start a new session with parametersGET /*- Dynamic content generation for any route
The application uses environment variables for configuration:
OPENROUTER_TOKEN- Your OpenRouter API tokenSESSION_SECRET- Secret for session encryptionPORT- Server port (default: 3000)
Manages available AI models:
- Loads models from cache
- Fetches updated models from OpenRouter
- Validates model selection
- Provides fallback models
Handles AI content generation:
- Generates content using OpenRouter API
- Cleans response content
- Manages prompt templates
- Handles API errors
The application includes comprehensive error handling:
- Global error middleware
- API error handling
- Graceful fallbacks for invalid models
- User-friendly error messages
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
ISC