CLI Reference
smartchats is the command-line interface for the SmartChats stack. One tool covers the entire lifecycle: install, configure, launch, observe, stop, sync with the cloud, and move data around.
Cloud auth is shared with the MCP server — log in once via smartchats login and any MCP-aware tool reading ~/.smartchats-mcp/credentials.json is authenticated too.
Install
See Quick Start. The two-second version:
curl -fsSL https://smartchats.ai/install | bashTop-level
smartchats <command> [options]If you run smartchats with no arguments:
- No config + no source reachable → runs
setup(guided first-run). - Config exists → runs
start. - Any flag present → routes to
launch(back-compat fornpx smartchats --no-promptscripted callers).
Use smartchats help <command> for per-command details, or <command> --help.
Lifecycle
smartchats setup
Guided first-run. Detects what’s installed, prompts for missing API keys, writes .env, and launches the stack.
smartchats setup [options]| Flag | Default | Notes |
|---|---|---|
--no-prompt | off | Use existing env / .env; skip interactive prompts |
--no-start | off | Just collect config; don’t start the stack |
--repo-path <path> | auto | Override where the smartchats source clone lives |
What it walks through, in order:
- Source — locates an existing smartchats checkout (
$SMARTCHATS_HOME, dir walk,config.smartchatsHome) or auto-clones one to~/.smartchats/cli/source. - System check — verifies the
bunruntime,surrealbinary, and free disk (≥ 3 GB). Prints install instructions for anything missing. - API keys — walks OpenAI / Anthropic / Google / Serper. For each, shows what it found in
$envor.envand lets you confirm or override. - Bearer token (optional) — for non-localhost deploys, configures
SMARTCHATS_API_KEY. - Persist + start — writes
.env, invokesstart. You’re at http://localhost:3000 when the wizard exits.
smartchats env
Interactively configure provider API keys. Same prompt loop as smartchats setup’s key step, scoped to just keys — no system check, no start. For when you’ve got a working install and want to rotate keys or enable a new provider (e.g. Serper for web search).
smartchats env [options]| Flag | Default | Notes |
|---|---|---|
--list, -l | off | Show what’s configured (masked); don’t prompt for changes. |
Walks each provider (OpenAI, Anthropic, Google Gemini, Serper). For each one, shows what’s already in $env or .env and lets you keep it, replace it, or remove it. Writes to the install root’s .env (typically ~/.smartchats/.env — the same file Docker mounts at /root/.smartchats/.env).
If the stack is running, restart afterward to pick up the new values:
smartchats restart # bare-metal install
docker restart <container> # docker installQuick “what’s configured” check without prompts:
smartchats env --list
# ✓ OpenAI sk-V…vGiE (env $OPENAI_API_KEY)
# ✓ Anthropic (Claude) sk-a…iQAA (env $ANTHROPIC_API_KEY)
# ✓ Google (Gemini) AIza…Uvbg (env $GEMINI_API_KEY)
# ✓ Serper (web search) 983d…4abf (env $SERPER_API_KEY)smartchats start
Launches the local stack as detached child processes. Idempotent — re-running while the stack is up + healthy is a no-op.
smartchats start [options]| Flag | Default | Notes |
|---|---|---|
--port <n> | 3000 | App port (browser connects here) |
--surreal-port <n> | 8000 | SurrealDB port (loopback only) |
--data-dir <path> | ~/.smartchats/data | Persistent SurrealDB storage |
--rebuild | off | Force turbo run build before start |
-f, --foreground | off | Attach to children; Ctrl-C stops the stack |
The stack is two processes: surreal and smartchats-server. The server hosts both the static SPA and the API at /local-api/* on the same port.
On detach (the default), start returns 0 once both processes have reported ready. PIDs are written to ~/.smartchats/run/pids.json.
smartchats stop
Stops the running stack. SIGTERM with a timeout, SIGKILL fallback. Idempotent.
smartchats stop [--timeout <ms>]smartchats restart
stop then start. All start flags forward verbatim.
smartchats restart [start-options...]smartchats status
Shows what’s running, on what ports, with what health. Exits 0 if the stack is up and serving; 1 otherwise.
smartchats status [--json]Example output:
surreal pid ✓ 12345 port ✓ 8000 up 2m 14s
server pid ✓ 12346 port ✓ 3000 up 2m 14s
✔ Stack healthy. Open: http://localhost:3000--json emits a machine-readable shape — useful in monitoring scripts.
smartchats logs
Tails per-process log files (~/.smartchats/logs/surreal.log, ~/.smartchats/logs/server.log).
smartchats logs [options]| Flag | Default | Notes |
|---|---|---|
-f, --follow | off | Stream new output (Ctrl-C to stop) |
--proc <surreal|server|all> | all | Which process(es) to show |
-n, --lines <n> | 50 | Initial line count |
smartchats dev
Hot-reload development stack. Delegates to bin/devserve in the smartchats source — Next.js dev with HMR, Express side-by-side, SurrealDB in Docker.
smartchats dev [-- <devserve-args>]Use this when you’re modifying SmartChats itself, not just running it. See Contributing for the development workflow.
Cloud
smartchats login
Browser-OAuth flow to the SmartChats cloud. Caches the refresh token at ~/.smartchats-mcp/credentials.json — same file the MCP server reads.
smartchats loginsmartchats logout
Clears cached cloud credentials.
smartchats logoutsmartchats whoami
Shows the currently-authenticated cloud user. Exits 1 if not logged in.
smartchats whoamismartchats data export
Exports user data (logs, KG triples, todos, voice settings) to a JSON bundle. Use for backups, debugging, migration between local + cloud.
smartchats data export <file> --target=<cloud|local>| Flag | Notes |
|---|---|
--target=cloud | Read from the hosted SmartChats cloud (requires smartchats login) |
--target=local | Read from a running local stack |
--include-sensitive | Include API key records (default: redacted) |
--url, --ns, --db | Override the local SurrealDB connection (target=local only) |
smartchats data import
Inverse of export. Upserts every row by id, so it’s safe to re-run.
smartchats data import <file> --target=<cloud|local>Meta
smartchats doctor
Environment health check. Diagnoses what’s installed, what’s running, and what’s reachable.
smartchats doctor [--port <n>] [--json]Checks (in order):
- SmartChats context — where is the source root?
- bun installed — required for the native-binary path.
- surreal installed — required.
- Free disk ≥ 3 GB — for builds + SurrealDB.
- Docker installed — informational (only needed if you’re using the legacy
launchpath or building the AIO image). - AIO image present — informational.
- Container
smartchatsrunning — informational. http://localhost:<port>responds — critical when a stack is supposed to be up.- Response is SmartChats — sanity check (catches port collisions).
- LLM provider keys — soft warning if none found.
Exits 0 if every critical check passes, 1 otherwise. --json emits the full result set as JSON.
smartchats home
Prints the resolved smartchats source root and how the CLI found it.
smartchats home [--path-only]--path-only prints just the path (or exits 1 with no output if no source is reachable) — useful for scripting:
cd "$(smartchats home --path-only)"Resolution order: $SMARTCHATS_HOME → dir walk → config.smartchatsHome (auto-clone remembers).
smartchats help <command>
Per-command help. Same as <command> --help.
Legacy
smartchats launch
Hidden from --help but still callable. The Docker AIO path (builds + runs smartchats-aio:latest). Use smartchats start for new installs.
smartchats launch [options]Kept for back-compat with scripted callers that depend on the pre-start interface.
Environment
| Variable | Default | Purpose |
|---|---|---|
SMARTCHATS_HOME | unset | Explicit path to the smartchats source. Overrides dir-walk and config-file fallbacks. |
SMARTCHATS_LOCAL_HOST | 127.0.0.1 | Upstream Express host that Next.js’s /local-api/* rewrite forwards to (dev mode) |
SMARTCHATS_LOCAL_PORT | 4242 | Upstream Express port |
SMARTCHATS_API_KEY | unset | Bearer token required on every /local-api/* request. Recommended for non-localhost deploys |
XDG_CONFIG_HOME | unset | If set, CLI config lives at $XDG_CONFIG_HOME/smartchats/config.json (else ~/.smartchats/config.json) |
SMARTCHATS_CREDENTIALS_FILE | ~/.smartchats-mcp/credentials.json | Cloud auth cache location |
NO_COLOR | unset | Disables CLI color output |
Provider keys (any of these are read; first match wins per provider):
| Provider | Aliases |
|---|---|
| OpenAI | OPENAI_API_KEY, SMARTCHATS_OPENAI_API_KEY |
| Anthropic | ANTHROPIC_API_KEY, SMARTCHATS_ANTHROPIC_API_KEY |
| Google (Gemini) | GOOGLE_API_KEY, SMARTCHATS_GOOGLE_API_KEY, GEMINI_API_KEY |
| Serper | SERPER_API_KEY, SMARTCHATS_SERPER_API_KEY |
Files
| Path | Purpose |
|---|---|
~/.smartchats/bin/ | Installed binaries |
~/.smartchats/data/ | SurrealDB rocksdb store |
~/.smartchats/run/pids.json | Live process state for the running stack |
~/.smartchats/logs/{surreal,server}.log | Per-process append logs |
~/.smartchats/config.json | CLI preferences (last port, resolved source root) |
~/.smartchats/cli/source/ | Default auto-clone location when no source is found |
~/.smartchats-mcp/credentials.json | Cloud OAuth cache, shared with the MCP server |
<repo>/.env | Provider keys + bearer token |
See also
- Quick Start — install + first-run.
- Self-Hosting — long-form deployment guide.
- Contributing — modifying SmartChats itself.
- MCP — expose smartchats to Claude Desktop and other MCP-aware tools via the shared credential store.