LLM Pricing Comparison Website - Complete Demo
Serves a static LLM pricing comparison website with a JSON API, interactive UI, and automated price scraping via Playwright and GitHub Actions.
What this file does
Serves a static LLM pricing comparison website with a JSON API, interactive UI, and automated price scraping via Playwright and GitHub Actions.
When to use it
- You need a ready-to-deploy pricing comparison site for LLM models
- You want automated daily price updates without manual maintenance
- You need a static JSON API for programmatic pricing access
- You want to demonstrate Playwright scraping and GitHub Actions integration
Assumes this stack
LLM Pricing Comparison Website - Complete Demo
π Project Overview
This project provides a comprehensive LLM pricing comparison website with:
- Static JSON API for programmatic access
- Interactive web interface with filtering and sorting
- Automated price updates using Playwright web scraping
- GitHub Pages deployment ready
π Project Structure
llmpricing/
βββ index.html # Main pricing comparison interface
βββ api.html # API documentation page
βββ data/
β βββ llm-pricing.json # Static JSON pricing data
βββ scripts/
β βββ update-pricing.js # Playwright scraper for live updates
βββ tests/
β βββ pricing-website.spec.js # Playwright tests for the website
β βββ live-scraping.spec.js # Tests for price scraping
βββ .github/
β βββ workflows/
β βββ update-pricing.yml # GitHub Actions for daily updates
βββ package.json # Node.js dependencies
βββ playwright.config.js # Playwright test configuration
βββ server.js # Local development server
π Features
1. Static JSON API
- Endpoint:
/data/llm-pricing.json - 30+ models from 7+ providers
- Structured data with pricing, features, context windows
- No rate limits - static file serving
2. Web Interface
- Real-time filtering by provider, category, search term
- Sorting by price, context window, provider
- Responsive design for mobile and desktop
- Statistics dashboard showing averages and counts
- Download JSON functionality
3. Automated Price Updates
- Playwright web scraping from official pricing pages
- GitHub Actions runs daily at 2 AM UTC
- Automatic commits of updated prices
- Error handling and reporting
4. Supported Providers
- OpenAI (GPT-4o, GPT-3.5, o1 models)
- Anthropic (Claude 3.5, Claude 3 family)
- Google AI (Gemini 1.5, Gemini 2.0)
- Meta Llama (via AWS Bedrock)
- Mistral AI
- Cohere
- Amazon Bedrock (Nova models)
π» Local Development
1. Install Dependencies
npm install
2. Start Local Server
# Using npm script
npm run serve
# Or using the custom server
node server.js
3. Access the Website
- Web Interface: http://localhost:8080
- JSON API: http://localhost:8080/data/llm-pricing.json
- API Docs: http://localhost:8080/api.html
π§ͺ Testing
Run Playwright Tests
# Run all tests
npx playwright test
# Run specific test file
npx playwright test tests/pricing-website.spec.js
# Run with UI
npx playwright test --ui
# Run in headed mode (see browser)
npx playwright test --headed
Update Prices Manually
# Run the price scraper
node scripts/update-pricing.js
# Or use npm script
npm run update-prices
π API Usage Examples
JavaScript
// Fetch pricing data
fetch('http://localhost:8080/data/llm-pricing.json')
.then(res => res.json())
.then(data => {
// Find cheapest model
const allModels = data.providers.flatMap(p =>
p.models.map(m => ({...m, provider: p.name}))
);
const cheapest = allModels.sort((a, b) =>
a.pricing.input - b.pricing.input
)[0];
console.log('Cheapest model:', cheapest);
});
Python
import requests
# Fetch pricing data
response = requests.get('http://localhost:8080/data/llm-pricing.json')
data = response.json()
# Find models with vision capabilities
vision_models = []
for provider in data['providers']:
for model in provider['models']:
if 'Vision' in model.get('features', []):
vision_models.append({
'provider': provider['name'],
'model': model['name'],
'price': model['pricing']['input']
})
print(f"Found {len(vision_models)} vision models")
cURL
# Get all pricing data
curl http://localhost:8080/data/llm-pricing.json
# Get specific provider (using jq)
curl http://localhost:8080/data/llm-pricing.json | \
jq '.providers[] | select(.name == "OpenAI")'
π Deployment to GitHub Pages
- Push to GitHub:
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/YOUR_USERNAME/llmpricing.git
git push -u origin main
- Enable GitHub Pages:
- Go to Settings β Pages
- Source: Deploy from a branch
- Branch: main
- Folder: / (root)
- Save
- Set up GitHub Secrets (optional for enhanced scraping):
- Go to Settings β Secrets β Actions
- Add
OPENAI_API_KEY(if available) - Add
COHERE_API_KEY(if available)
- Access Your Site:
- URL:
https://YOUR_USERNAME.github.io/llmpricing/ - API:
https://YOUR_USERNAME.github.io/llmpricing/data/llm-pricing.json
π Automated Updates
The GitHub Actions workflow (update-pricing.yml) will:
- Run daily at 2 AM UTC
- Use Playwright to scrape pricing pages
- Update the JSON file
- Commit changes automatically
- Deploy to GitHub Pages
To manually trigger an update:
- Go to Actions tab
- Select "Update LLM Pricing Data"
- Click "Run workflow"
π― Use Cases
- Price Comparison: Compare costs across providers
- Model Selection: Find models by features (vision, context length)
- Budget Planning: Calculate costs for specific token usage
- API Integration: Programmatically access pricing in your apps
- Market Analysis: Track pricing trends over time
π οΈ Playwright Browser Automation
The project uses Playwright for:
- Web scraping pricing data
- Testing the web interface
- Automating updates
Key capabilities demonstrated:
- Navigate to pricing pages
- Extract structured data
- Handle dynamic content
- Take screenshots
- Run in headless mode
π Statistics at a Glance
Current coverage (as of last update):
- 7 Providers
- 30+ Models
- Average Input Price: ~$2.50/1M tokens
- Average Output Price: ~$10/1M tokens
- Max Context Window: 2M tokens (Gemini 1.5 Pro)
π§ Troubleshooting
Port Already in Use
# Kill process on port 8080
npx kill-port 8080
# Or use a different port
npx http-server -p 3000
Playwright Installation
# Install browsers
npx playwright install chromium
Update Failures
- Check network connectivity
- Verify website structures haven't changed
- Review error logs in GitHub Actions
π License
MIT License - Feel free to use this for any purpose!
π€ Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests if applicable
- Submit a pull request
π Support
- Create an issue on GitHub
- Check the API documentation at
/api.html - Review test files for usage examples
Live Demo: Deploy to GitHub Pages for a live version! API Endpoint: Access JSON data programmatically for your applications!
What's inside
12 sections covering project structure, features, local dev, testing, API examples, deployment, automation, troubleshooting, and contributing
Change this for your project
- Replace
YOUR_USERNAMEin GitHub URLs with your GitHub username - Replace
YOUR_USERNAME.github.io/llmpricingwith your actual GitHub Pages URL - Replace
https://github.com/YOUR_USERNAME/llmpricing.gitwith your repository URL
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Using a static JSON file as a zero-cost API with no rate limits
- Combining Playwright scraping with a scheduled GitHub Action for automated data freshness
- Providing both a web interface and programmatic access from the same data source
Related Documents
MCP Integration Workflows and Orchestration Guide
Defines enterprise-grade integration patterns, orchestration strategies, and advanced workflows for MCP servers with code examples.
Valet V1 β Architecture & Implementation Plan
Defines a hosted background coding agent platform with isolated sandboxed dev environments, multiplayer sessions, and YAML-driven workflows.
Writing Effective Skills
Distills patterns from production agent skills across multiple frameworks into actionable design principles for writing skills that agents actually follow.
AutoDoc Demo: Step-by-Step Walkthrough
Walks through setting up AutoDoc in a target repository and triggering automated documentation generation from code changes.