LLM Chess is a lightweight browser-based chess experience where you play against a large-language-model-powered opponent using your own OpenAI API key.
- The UI (
index.html,static/js/game.js,static/css/style.css) renders a chessboard via Chessboard.js + Chess.js. - When it's the AI's turn, the frontend posts directly to
https://api.openai.com/v1/chat/completionswith the stored OpenAI key so the AI can reason about the position and return a JSON move. - Illegal-move detection and a simple overlay enforce a clean experience, while API keys live only in the user's browser
localStorage. - A legacy Flask server (
app.py) still exists but is currently dormant and not used by the UI; you can remove it if you want a pure static deployment.
- Install dependencies and run a local dev server (optional):
The Flask app serves the static pages on
python -m venv venv source venv/bin/activate pip install -r requirements.txt python app.pyhttp://localhost:5001, but the UI now calls OpenAI directly. - Alternatively, open
index.htmlin a static hosting environment (GitHub Pages, Netlify, etc.). - Click the settings icon, paste your OpenAI API key, and start a new game. The key is stored only in your browser.
- Only models starting with
gptare listed; feel free to extend the dropdown if you plan to support other providers again. - Because the browser makes requests straight to OpenAI, make sure your key stays private (don’t paste it in shared browsers).
- The project keeps the Flask backend around in case you want to reintroduce a proxy, but it’s not required for the current experience.