A beautiful, GitHub-inspired AI chat application built with HTML, CSS, and JavaScript. Perfect for teaching students about LLM API integration!
- Modern GitHub-inspired UI with dark theme
- Glowing effects and animated particles background
- Free LLM API integration (multiple options provided)
- Responsive design optimized for programmers
- Real-time chat interface
- Syntax highlighting for code blocks
- Clean, well-commented code for educational purposes
- Visit Groq Console
- Sign up for a free account
- Navigate to "API Keys" section
- Click "Create API Key"
- Copy your API key
- Open
script.jsand replace'YOUR_API_KEY_HERE'with your key
Benefits:
- Very fast inference
- Generous free tier
- Multiple models available (Llama 3, Mixtral, etc.)
- No credit card required
- Visit Hugging Face
- Create a free account
- Go to Settings → Access Tokens
- Create a new token with "Read" permissions
- Copy your token
- In
script.js, update the API configuration to use Hugging Face
Benefits:
- Thousands of models available
- Free tier available
- Great for experimentation
- Visit OpenRouter
- Sign up for free
- Get your API key from the dashboard
- Some models are completely free
AI/
├── index.html # Main HTML structure
├── styles.css # GitHub-inspired styling
├── script.js # Chat logic and API integration
├── particles.js # Particle animation system
└── README.md # This file
- Simple, semantic HTML structure
- Chat container with message display area
- Input field for user messages
- Settings panel for API configuration
- GitHub-inspired color scheme
- Glowing effects using CSS filters and animations
- Smooth transitions and hover effects
- Particle canvas background
- Captures user input
- Sends requests to LLM API
- Displays responses in real-time
- Handles errors gracefully
The application uses the Fetch API to communicate with LLM services:
// Basic structure
fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
messages: chatHistory,
model: selectedModel
})
})- API Basics: Learn how to make HTTP requests to external services
- Async/Await: Understanding asynchronous JavaScript
- DOM Manipulation: Dynamically updating the page
- Event Handling: Responding to user interactions
- Error Handling: Managing API failures gracefully
- CSS Animations: Creating engaging visual effects
- Canvas API: Drawing particle animations
You can easily switch between different APIs by modifying the configuration in script.js:
const CONFIG = {
API_KEY: 'your-api-key-here',
API_ENDPOINT: 'https://api.groq.com/openai/v1/chat/completions',
MODEL: 'llama-3.1-8b-instant'
};- Colors: Modify CSS variables in
styles.css - Particles: Adjust particle count and behavior in
particles.js - Models: Change the LLM model in
script.js - UI Layout: Modify HTML structure in
index.html
- Simply open
index.htmlin a modern web browser - No build process or server required!
- Enter your API key in the settings
- Start chatting!
- API Keys: Never commit API keys to version control
- Rate Limits: Free tiers have usage limits
- CORS: Some APIs may require a backend proxy for production
- Security: In production, API calls should go through your backend
- CORS Errors: Try a different API or set up a simple backend proxy
- API Key Invalid: Double-check your key and ensure it's active
- No Response: Check browser console for error messages
- Slow Responses: Try a different model or API provider
This is an educational project! Feel free to:
- Experiment with different APIs
- Improve the UI/UX
- Add new features (voice input, file uploads, etc.)
- Optimize the code
This project is free to use for educational purposes.
Happy Learning! 🚀