Single-user personal AI chat app built with Flask, SQLite, and vanilla JavaScript (ES modules).
It supports streamed responses, model/tool calling, optional image uploads, and local conversation history.
- Password-protected login
- Server-sent event (SSE) streaming responses
- Conversation history stored in SQLite
- OpenRouter model support
- Optional Google AI Studio model support
- Tool support:
web_search(SearXNG)web_fetchrun_python(sandboxed Python execution)
- Python 3.10+ (recommended)
- An OpenRouter API key
- Clone and enter the repo.
- Create and activate a virtual environment.
- Install dependencies:
pip install -r requirements.txt- Create your environment file from the template:
cp .env.template .env-
Set at least:
OPENROUTER_API_KEYSECRET_KEY(32+ chars, random)
-
Set the login password (interactive terminal required):
python3 set_password.py- Run the app:
python3 app.pyThe app runs on port 8001 by default.
See .env.template for the full list.
Core values:
OPENROUTER_API_KEY(required)SECRET_KEY(required)FLASK_ENV(developmentorproduction)SESSION_COOKIE_SECURE(truewhen served over HTTPS/proxy)TRUST_X_FORWARDED_FOR(truebehind trusted reverse proxy)SEARXNG_URL(optional, forweb_search)GOOGLE_AI_STUDIO_API_KEY(optional)ENABLE_UNSAFE_PYTHON_TOOL(safety toggle)ENABLE_BROWSER_FETCH(safety toggle)
app.py— Flask app, routes, streaming chat loop, model/tool orchestrationauth.py— password hash, login checks, CSRF, rate limitingdatabase.py— SQLite schema and conversation/message persistenceconfig.py— environment-driven configset_password.py— interactive password setuptools/— tool implementations (web_search,web_fetch,python_sandbox)static/,templates/— frontend assets and HTML templates
set_password.pymust be run in a real interactive terminal.- For production, run behind HTTPS and set secure cookie/proxy settings accordingly.