Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalAI logo

LocalAI

Free. Local. Private. A ChatGPT-style AI workstation that runs entirely on your machine — powered by OpenRouter and hundreds of free models.

No Ollama. No GPU. No heavy runtime. No account. Just Python.

LocalAI

Python FastAPI OpenRouter AES-256 Tor License

local-ai · openrouter · free-ai · chatgpt-alternative · self-hosted · privacy · tor · no-gpu · offline-first · ai-coding-assistant · local-llm · encrypted · sandbox


Why LocalAI?

Running powerful models usually means Ollama, a beefy GPU, gigabytes of downloads and a hot laptop. LocalAI takes the opposite path: it stays tiny and lets OpenRouter's free tier do the heavy lifting in the cloud, while everything that matters — your API token, your conversations, your files — never leaves your computer and is sealed with AES-256.

You get a beautiful, ChatGPT-like web app on http://localhost:2234, multiple AI characters, a sandboxed coding agent, live syntax highlighting, six themes, optional HTTPS and optional Tor routing — all from a single python run.py.

LocalAI interface


Features

  • Zero-config free AI — automatically lists OpenRouter's free models, ranked best-to-worst. Switch models any time from the top bar.
  • One master password — on first launch you enter your OpenRouter token + a password. The token is sealed into secret.bin using an AES-256 key derived from your password (PBKDF2, 200k iterations). Forget the password and everything resets.
  • Encrypted chat history — every message is stored in a local SQLite database, encrypted with your key. Corrupt DB? It self-heals and backs up the bad copy.
  • AI characters as packages — each character is a folder with a character.json + avatar. Built-in Coder (sandboxed autonomous coding agent) and Jessica (a warm AI companion). Create your own from the UI with a custom system prompt, theme, greeting and profile photo. Every character keeps its own separate conversations — they never mix.
  • Ironclad sandbox — the Coder agent can read, write, edit, list and delete files, but only inside its workspace. Path traversal is blocked at the core.
  • Live agent steps — every tool the AI runs is streamed to the UI in real time.
  • Six themes — Monochrome, Dark, Light, Midnight, Terminal Green, Rose. Your theme and model choice are remembered via cookies.
  • Syntax highlighting, file upload, stop-generation, and a built-in sandbox file browser.
  • DoS / DDoS protection — per-IP sliding-window rate limiting with automatic temporary bans and payload-size limits. No account or login required — anyone on your machine/LAN can just chat.
  • Optional HTTPS — run with --https and LocalAI generates a self-signed certificate for you (and tells you exactly where it lives).
  • Optional Tor — run with -tor and all OpenRouter traffic is routed through Tor at 127.0.0.1:9050 using socks5h (DNS resolved through Tor too — no leaks).

What's new in v2

  • DuckDuckGo web search (no API key) — queries the html.duckduckgo.com/html endpoint, parses titles/links/snippets and feeds them to the model as context. Exposed both as a web_search tool (permission-gated) and a /api/search endpoint.
  • Sandboxed command execution — the AI can now run shell commands through a hardened run_command tool: strict executable whitelist + dangerous-token blacklist, shell=False (no pipes/redirection escapes), a working directory pinned to the sandbox, a wall-clock timeout, and POSIX resource limits (CPU, memory, file-size, process count) applied via setrlimit in a fresh session group. Network tools (curl, wget, ssh, ...) and privilege tools (sudo, chmod, ...) are blocked.
  • Granular per-character permissions — instead of one on/off "tools" switch, every character/model now carries three independent permissions: File read/write, Sandbox commands, Web search. Editable at creation and afterwards via the ✎ edit button.
  • Reworked model picker — live filter box, Free-only / All toggle, an Uncensored filter, and readable names. Uncensored / abliterated / roleplay models and Chinese providers (Qwen, DeepSeek, Tencent/Hunyuan, Zhipu/GLM, Yi, MiniMax, Moonshot/Kimi) are surfaced prominently. Add your own model with +.
  • Encrypted uploads — tick Encrypt uploaded files and an uploaded file is sealed with your session AES-256 key (stored as *.enc) before it touches disk.
  • UI/UX polish — glassy sticky header, grain texture, animated drag-&-drop upload overlay, expandable composer with a live character counter, one-click copy buttons on every code block, permission chips on character cards, and refreshed typography (Sora / Inter / JetBrains Mono).

Installation

git clone https://github.com/X-croot/LocalAI.git
cd LocalAI
pip install -r requirements.txt

Requires Python 3.9+. That's it — no models to download, no GPU needed.


Usage

Start the server (default port 2234, over HTTP):

python run.py

Open http://localhost:2234 in your browser.

On first launch you'll be asked for:

  1. your OpenRouter API token — get one free at https://openrouter.ai/keys
  2. a master password — this encrypts your token and all future chats.

On every later launch you just enter your password to unlock.

Command-line flags

Flag Description
--port <n> Port to serve on (default 2234)
--host <ip> Bind address (default 0.0.0.0)
--https Serve over HTTPS with an auto-generated self-signed certificate
-tor / --tor Route all OpenRouter traffic through Tor (127.0.0.1:9050)

Examples:

python run.py --https                 # HTTPS on https://localhost:2234
python run.py -tor                    # everything through Tor
python run.py --https -tor --port 8443
Tor

Tor mode

With -tor, LocalAI never talks to OpenRouter directly. It sends every request through the Tor SOCKS proxy on 127.0.0.1:9050 using socks5h://, so even DNS resolution happens inside Tor. Make sure the Tor daemon (or Tor Browser) is running and listening on 9050 before you start.

# Debian/Ubuntu
sudo apt install tor && sudo service tor start
python run.py -tor

AI Characters

Characters live in the characters/ folder. Each is a self-contained package:

characters/
  coder/
    character.json
    avatar.jpg
  jessica/
    character.json
    avatar.jpg

character.json:

{
  "name": "Coder",
  "description": "Sandboxed autonomous coding assistant.",
  "system_prompt": "You are Coder...",
  "theme": "monochrome",
  "greeting": "Hey, I'm Coder...",
  "tools_enabled": true,
  "avatar": "avatar.jpg"
}
Coder    Jessica

Create a new character straight from the picker screen (+ Create a character) — set a name, system prompt, greeting, theme, whether it can use sandbox file tools, and upload a profile photo. It instantly appears on the home menu with its own isolated chat history.


How it works

run.py            entrypoint, CLI flags, HTTPS + Tor setup, launches uvicorn
server.py         FastAPI app: setup/unlock, chat SSE + tool loop, files, characters
core/
  crypto_store.py PBKDF2 -> AES-256-GCM, secret.bin sealing + file encryption
  database.py     encrypted SQLite chat storage + integrity self-heal
  openrouter.py   OpenRouter client (model listing, uncensored/CN detection, chat)
  sandbox.py      hardened file ops + isolated whitelisted command execution
  websearch.py    API-key-free DuckDuckGo HTML search
  ratelimit.py    per-IP DoS/DDoS protection
  certs.py        self-signed certificate generation
  characters.py   character package loader/creator with granular permissions
static/           HTML + CSS themes + vanilla JS frontend

Generated at runtime (git-ignored, stays on your machine):

localai_data/
  secret.bin      your AES-encrypted OpenRouter token
  chats.db        your encrypted conversations
  workspace/      the Coder sandbox
  cert.pem/key.pem  (only with --https)

Security notes

  • Token & chats are encrypted with AES-256-GCM; the key is derived from your password via PBKDF2-HMAC-SHA256 (200,000 iterations) and is never written to disk.
  • The sandbox rejects any path that resolves outside the workspace root.
  • Rate limiting protects against floods without requiring accounts.
  • Self-signed HTTPS certs are for local/LAN use — your browser will warn once; that's expected.

Disclaimer

LocalAI is an independent open-source client for the OpenRouter API. It is not affiliated with OpenRouter, The Tor Project, OpenAI, Anthropic or Google. You are responsible for your own API usage and for complying with the terms of any model or network you use. Model availability, quality and "free" status are controlled by OpenRouter and can change at any time. Self-signed certificates provide encryption but not identity verification. Use Tor mode responsibly and in accordance with your local laws. Provided as-is, without warranty of any kind.

License

MIT © X-croot

Made for people who want powerful AI without the heavy machinery.

⭐ Star it on GitHub if LocalAI saved you a GPU.

About

Local-AI: Run Coder & Uncensored LLMs via Ollama-Compatible API, No GPU Required

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages