Personal AI Gateway โ Pure Python, zero-dependency AI assistant with multi-model routing, web UI, and 67 built-in tools
Project description
What is SalmAlm?
SalmAlm is a personal AI gateway โ one Python package that gives you a full-featured AI assistant with a web UI, Telegram/Discord bots, 62 tools, browser automation, sub-agents, and memory system.
No Docker. No Node.js. No config files. Just:
pip install salmalm
salmalm
# โ http://localhost:18800
First launch opens a Setup Wizard โ paste an API key, pick a model, done.
โ ๏ธ Don't run
salmalmfrom inside a cloned repo directory โ Python will import the local source instead of the installed package. Run from~or any other directory.
Why SalmAlm?
| Feature | SalmAlm | ChatGPT | OpenClaw | Open WebUI | |
|---|---|---|---|---|---|
| ๐ง | Install complexity | pip install |
N/A | npm + config | Docker |
| ๐ค | Multi-provider routing | โ Auto 3-tier | โ | โ | โ |
| ๐ง | Memory (2-layer + auto-recall) | โ | โ | โ | โ |
| ๐ค | Sub-agents (spawn/steer/notify) | โ | โ | โ | โ |
| ๐ | Browser automation (Playwright) | โ | โ | โ | โ |
| ๐ง | Extended Thinking (4 levels) | โ | โ | โ | โ |
| ๐ | Encrypted Vault (AES-256-GCM) | โ | โ | โ | โ |
| ๐ฑ | Telegram + Discord | โ | โ | โ | โ |
| ๐งฉ | MCP (Model Context Protocol) | โ | โ | โ | โ |
| ๐ฆ | Local LLM (Ollama/LM Studio/vLLM) | โ | โ | โ | โ |
| ๐ฆ | Zero dependencies* | โ | N/A | โ | โ |
| ๐ฐ | Cost optimization (83% savings) | โ | โ | โ | โ |
*stdlib-only core; optional cryptography for AES-256-GCM vault
โก Quick Start (5๋ถ์ด๋ฉด ์ถฉ๋ถํฉ๋๋ค)
Step 1: ์ค์น (30์ด)
pip install salmalm
Step 2: ์คํ (10์ด)
salmalm --open
# โ ๋ธ๋ผ์ฐ์ ๊ฐ ์๋์ผ๋ก ์ด๋ฆฝ๋๋ค (http://localhost:18800)
# ๋๋ (editable install์์ console_script๊ฐ ์ ๋ ๋):
python3 -m salmalm --open
Step 3: API ํค ์ ๋ ฅ (2๋ถ)
- ์น UI์ Setup Wizard๊ฐ ์๋์ผ๋ก ๋น๋๋ค
- AI ์ ๊ณต์ฌ์ API ํค๋ฅผ ๋ถ์ฌ๋ฃ๊ธฐ ํ์ธ์:
- Anthropic Console โ API Keys
- OpenAI Platform โ API Keys
- ๋๋ Google AI Studio โ API Keys
- "Save" ํด๋ฆญ โ ๋!
Step 4: ๋ํ ์์ (๋ฐ๋ก!)
"์ค๋ ๋ ์จ ์ด๋?" โ ์น ๊ฒ์ + ๋ต๋ณ
"์ด ์ฝ๋ ๋ฆฌ๋ทฐํด์ค" โ ํ์ผ ์ฝ๊ธฐ + ๋ถ์
"/model sonnet" โ ๋ชจ๋ธ ๋ณ๊ฒฝ
"/help" โ ์ ์ฒด ๋ช
๋ น์ด ๋ณด๊ธฐ
๐ก ์์ฐ์ด๋ก ๋งํ๋ฉด ๋ฉ๋๋ค. 62๊ฐ ๋๊ตฌ๋ฅผ AI๊ฐ ์์์ ์ ํํฉ๋๋ค. ๋ช ๋ น์ด๋ฅผ ์ธ์ธ ํ์ ์์ด, ํ๊ณ ์ถ์ ๊ฑธ ๊ทธ๋ฅ ๋งํ์ธ์.
๊ณ ๊ธ ์ต์
salmalm --shortcut # ๋ฐํํ๋ฉด ๋ฐ๋ก๊ฐ๊ธฐ ์์ฑ
salmalm doctor # ์๊ฐ์ง๋จ
salmalm --update # ์๋ ์
๋ฐ์ดํธ
SALMALM_PORT=8080 salmalm # ํฌํธ ๋ณ๊ฒฝ
Supported Providers (Auto-Routing)
| Provider | Models | Tier |
|---|---|---|
| Anthropic | Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 | Complex / Moderate / Simple |
| OpenAI | GPT-5.2, GPT-5, o4-mini | Complex / Moderate |
| Gemini 3.1 Pro, 2.5 Flash | Moderate / Simple | |
| xAI | Grok-4, Grok-3-mini | Complex / Simple |
| DeepSeek | R1, Chat | Via OpenRouter |
| Local LLM | Ollama / LM Studio / vLLM | Auto-detected |
๐ง Architecture
Browser โโWebSocketโโโบ SalmAlm โโโบ Anthropic / OpenAI / Google / xAI / Local
โ โ
โโโHTTP/SSEโโโบ โโโ Smart Model Router (3-tier: simple/moderate/complex)
โโโ Engine Pipeline (classify โ route โ context โ execute)
Telegram โโโบ โโโ Memory System (2-layer + auto-recall + TF-IDF RAG)
Discord โโโบ โโโ Sub-Agent Manager (spawn/steer/kill/notify)
โโโ Tool Registry (62 tools, risk-tiered)
โโโ Browser Automation (Playwright subprocess)
โโโ Security Middleware (auth/CSRF/CSP/rate-limit/audit)
โโโ Vault (PBKDF2-200K + AES-256-GCM)
โโโ Cron / Backup / Self-Diagnostics
Codebase Metrics
| Metric | Value |
|---|---|
| Python files | 192 |
| Total lines | ~52,450 |
| Functions | ~1,800 |
| Max cyclomatic complexity | 20 (all functions) |
| Largest file | 778 lines |
| Files > 800 lines | 0 |
| Docstring coverage | 99% |
| Return type hints | 81% |
| Tests | 1,878 passing |
๐ฏ Feature Overview
Core AI Engine
- 3-tier auto-routing โ simpleโHaiku ($1/M), moderateโSonnet ($3/M), complexโGPT-5.2/Sonnet ($2-3/M)
- Extended Thinking โ 4 levels (low/medium/high/xhigh) with budget control
- Cross-provider message sanitization โ seamless model switching mid-conversation
- 5-stage context compaction โ strip binary โ trim tools โ drop old โ truncate โ LLM summarize
- Prompt caching โ Anthropic cache_control for 90% cost reduction
- Model failover โ exponential backoff + retry across providers
- Infinite loop detection โ 3+ same (tool, args_hash) in last 6 iterations = auto-break
Memory System (OpenClaw-style)
- 2-layer architecture โ
MEMORY.md(curated long-term) +memory/YYYY-MM-DD.md(daily logs) - Auto-recall โ searches memory before each response, injects relevant context
- Auto-curation โ promotes important daily entries to long-term memory
- TF-IDF + cosine similarity search across all memory files
- Memory scrubbing โ API keys/secrets auto-redacted before storage
Sub-Agent System
- Spawn background AI workers with independent sessions
- Thinking level per agent (low/medium/high/xhigh)
- Labels for human-readable naming
- Steer running agents with mid-task guidance
- Auto-notify on completion (WebSocket + Telegram push)
- Collect results (push-style, like OpenClaw)
/subagents spawn Review this PR --model sonnet --thinking high --label pr-review
/subagents list
/subagents steer abc123 Focus on security issues
/subagents kill abc123
/subagents collect
62 Built-in Tools
Web search (Brave), email (Gmail), calendar (Google), file I/O, shell exec, Python eval (opt-in), image generation (DALL-E/Aurora), TTS/STT, browser automation (Playwright), RAG search, QR codes, system monitor, OS-native sandbox, mesh networking, and more.
Web UI
- Real-time streaming (SSE-first, WebSocket for typing indicators)
- Embedding RAG โ hybrid vector search (OpenAI/Google embeddings + BM25 fallback)
- Agent steer โ
/agent steer <label> <message>to control running sub-agents - Browser aria-ref compression โ 10x token savings for browser automation
- Thinking stream UI โ real-time collapsible thinking display
- Session branching, rollback, search (
Ctrl+K), command palette (Ctrl+Shift+P) - Dark/Light themes, EN/KR i18n
- Image paste/drag-drop with vision, code syntax highlighting
- Settings panels: Engine, Routing, Telegram, Discord, Memory, Cron, Backup
- PWA installable
Channels
- Web โ full SPA at
localhost:18800 - Telegram โ polling + webhook with inline buttons
- Discord โ bot with thread support and mentions
โจ Unique Features
| Feature | What it does |
|---|---|
| Self-Evolving Prompt | AI auto-generates personality rules from conversations |
| Dead Man's Switch | Emergency actions if you go inactive for N days |
| Shadow Mode | AI learns your style, replies as you when away |
| Life Dashboard | Unified health, finance, habits, calendar view |
| Mood-Aware Response | Detects emotional state, adjusts tone |
| A/B Split Response | Two model perspectives on the same question |
| Time Capsule | Schedule messages to your future self |
| Thought Stream | Private journaling with hashtag search and mood tracking |
๐ฐ Cost Optimization
SalmAlm is designed to minimize API costs without sacrificing quality:
| Feature | Effect |
|---|---|
| Dynamic tool loading | 62 tools โ 0 (chat) or 7-12 (actions) per request |
| 3-tier auto-routing | Simpleโ$1/M, Moderateโ$3/M, Complexโ$3/M (no Opus needed) |
| Tool schema compression | 7,749 โ 693 tokens (91% reduction) |
| System prompt compression | 762 โ 310 tokens |
| Intent-based max_tokens | Chat 512, search 1024, code 4096 |
| Intent-based history trim | Chat 10 turns, code 20 turns |
| Cache TTL | Same question cached (30minโ24h, configurable) |
| Cross-provider failover | Falls back to cheaper model on rate limit |
Result: $7.09/day โ $1.23/day (83% savings at 100 calls/day)
๐ Security
Dangerous features default OFF โ everything requires explicit opt-in:
| Feature | Default | Opt-in |
|---|---|---|
| Network bind | 127.0.0.1 |
SALMALM_BIND=0.0.0.0 |
| Shell operators | Blocked | SALMALM_ALLOW_SHELL=1 |
| Python eval | Disabled | SALMALM_PYTHON_EVAL=1 |
| Home dir file read | Workspace only | SALMALM_ALLOW_HOME_READ=1 |
| Plugin system | Disabled | SALMALM_PLUGINS=1 |
Security Hardening
- SSRF defense โ DNS pinning + private IP block on every redirect hop
- Tool risk tiers โ Critical tools blocked on external bind without auth
- CSRF โ Origin validation +
X-Requested-Withheader - CSP โ Strict nonce mode available
- Audit log โ secrets scrubbed before logging (9 pattern types)
- Memory scrubbing โ API keys auto-redacted before storage
- Path validation โ
Path.is_relative_to()for all file operations - Session isolation โ user_id scoped, export restricted to own data
- Node dispatch โ HMAC-SHA256 signed payloads
- 150+ security regression tests in CI
See SECURITY.md for full threat model.
๐ฆ Local LLM Setup
| Server | Endpoint | Setup |
|---|---|---|
| Ollama | http://localhost:11434/v1 |
ollama serve |
| LM Studio | http://localhost:1234/v1 |
Start server in LM Studio |
| vLLM | http://localhost:8000/v1 |
vllm serve <model> |
Settings โ Local LLM โ paste endpoint โ Save. Models auto-discovered.
๐ง Configuration
# Server
SALMALM_PORT=18800 # Web server port
SALMALM_BIND=127.0.0.1 # Bind address
SALMALM_HOME=~/SalmAlm # Data directory
# AI
SALMALM_PLANNING=1 # Planning phase (opt-in)
SALMALM_REFLECT=1 # Reflection pass (opt-in)
SALMALM_MAX_TOOL_ITER=25 # Max tool iterations
SALMALM_COST_CAP=0 # Daily cost cap (0=unlimited)
# Security
SALMALM_PYTHON_EVAL=1 # Enable python_eval tool
SALMALM_PLUGINS=1 # Enable plugin system
SALMALM_ALLOW_SHELL=1 # Enable shell operators
All settings also available in Web UI โ Settings.
๐ค Contributing
git clone https://github.com/hyunjun6928-netizen/salmalm.git
cd salmalm
pip install -e ".[dev]"
python -m pytest tests/ -q --timeout=30 -x \
--ignore=tests/test_multi_tenant.py \
--ignore=tests/test_fresh_install_e2e.py
See CONTRIBUTING.md.
๐ License
SalmAlm = ์ถ(Life) + ์(Knowledge)
Your life, understood by AI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file salmalm-0.19.77.tar.gz.
File metadata
- Download URL: salmalm-0.19.77.tar.gz
- Upload date:
- Size: 814.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
047e1a57d2e4b48b71048def60237733dfebe97b5bdadca353e87194b81fd552
|
|
| MD5 |
2cf86f6876fe17e481a06e4d7357f82e
|
|
| BLAKE2b-256 |
9a394de409ca6e03a1193341efe8410e21c478a8f4527ec4bb1fe0921ab42503
|
File details
Details for the file salmalm-0.19.77-py3-none-any.whl.
File metadata
- Download URL: salmalm-0.19.77-py3-none-any.whl
- Upload date:
- Size: 792.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92ab435c37420e399cac1792279708d24f7fa410a6e6184efed7b241dd613bf5
|
|
| MD5 |
479bded61ffd8b8c0f4ca43f4ade2964
|
|
| BLAKE2b-256 |
16b4e4501430e32e89b7a0b66c6fbc2120e0ed10e33d49508284ed7ee2867337
|