CLI Reference
smartchats is the command-line interface for the SmartChats stack. One tool covers the whole lifecycle: install, configure, launch, observe, stop, upgrade, sign in to the cloud, and move data around.
Cloud auth is shared with the MCP server. Log in once with smartchats login and any tool reading ~/.smartchats-mcp/credentials.json is authenticated too.
Install
See Quick Start. The short version:
curl -fsSL https://smartchats.ai/install | bashTop-level
smartchats <command> [options]If you run smartchats with no arguments:
- No config and no source reachable → runs
setup(guided first run). - Otherwise → runs
starton the last-used port.
If the first argument is a flag other than --help or --version, the CLI routes to the legacy launch command (for older npx smartchats --no-prompt scripts).
To check the installed version, run:
smartchats --version
# Output: 0.x.y-v and -V work too. Use smartchats help <command> or smartchats <command> --help for per-command details.
Lifecycle
smartchats setup
Guided first run. Detects the install, checks the system, prompts for API keys, writes .env, and starts the stack.
smartchats setup [options]| Flag | Default | Notes |
|---|---|---|
--no-prompt | off | Use existing env / .env values. Skip all prompts |
--no-start | off | Collect config only. Don’t start the stack |
--repo-path <path> | ~/.smartchats/cli/source | Where to clone the source (source and npm installs only) |
What it walks through, in order:
- Install: a binary install uses
~/.smartchats. Otherwise it locates a source checkout ($SMARTCHATS_HOME, a directory walk,config.smartchatsHome) or clones one to~/.smartchats/cli/source($XDG_DATA_HOME/smartchats/cli/sourceif that variable is set). - System check: free disk (warns below 3 GB). Source and npm installs also need
bunandsurreal, and setup stops with an install command if either is missing. - API keys: walks OpenAI, Anthropic, Google and Serper. For each, it shows what it found in your environment or
.envand lets you keep or replace it. - Write + start: writes
.envand runsstart. The stack is up at http://localhost:3000 when the wizard exits.
smartchats env
Interactively configure provider API keys. Same prompt loop as the key step of setup, with no system check and no start. Use it to rotate keys or enable a provider later.
smartchats env [options]| Flag | Default | Notes |
|---|---|---|
-l, --list | off | Show what’s configured (masked). Don’t prompt |
It walks OpenAI, Anthropic, Google (Gemini) and Serper. For each one it shows what’s already set and lets you keep it, replace it, or remove it. It writes to ~/.smartchats/.env for a binary install (the same file you mount into Docker at /root/.smartchats/.env) or <repo>/.env for a source install.
env doesn’t prompt for xAI, Together AI or Azure Speech. Add XAI_API_KEY, TOGETHER_API_KEY, AZURE_SPEECH_KEY and AZURE_SPEECH_REGION to the .env file by hand. See Required environment.
If the stack is running, restart afterwards to pick up the new values:
smartchats restart # bare-metal install
docker restart smartchats # docker installTo check what’s configured without prompts, run:
smartchats env --list
# Output:
# ✓ 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) not set (optional)smartchats start
Launches the local stack as detached child processes. Re-running while the stack is up and healthy prints the URL and exits.
smartchats start [options]| Flag | Default | Notes |
|---|---|---|
--port <n> | 3000 | App port (browser connects here) |
--surreal-port <n> | 8000 | SurrealDB port (binds to 127.0.0.1) |
--data-dir <path> | ~/.smartchats/data | SurrealDB storage. The database is <data-dir>/surreal.db |
--rebuild | off | Source mode only: run the workspace build before starting. Ignored in a binary install |
-f, --foreground | off | Stay attached. Ctrl-C or SIGTERM stops both processes |
--no-prompt | off | Skip the “configure keys now?” prompt that appears when no provider key is found. Use in scripts, CI and Docker |
The stack is two processes: surreal and smartchats-server. The server hosts the static SPA and the API at /local-api/* on the same port. It always binds to 0.0.0.0.
start reads .env from the install root (or repo root) and your shell environment. A shell variable wins over the same name in .env.
When detached (the default), start returns 0 once both processes report ready. PIDs are written to ~/.smartchats/run/pids.json.
smartchats stop
Stops the running stack. Sends SIGTERM, waits, then sends SIGKILL.
smartchats stop [--timeout <ms>]| Flag | Default | Notes |
|---|---|---|
--timeout <ms> | 5000 | How long to wait after SIGTERM before SIGKILL |
smartchats restart
stop, then start. All start flags are forwarded.
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]To check the stack, run:
smartchats status
# Output:
# surreal pid ✓ 12345 port ✓ 8000 up 2m 14s
# server pid ✓ 12346 port ✓ 3000 up 2m 14s
#
# ✔ Stack healthy. Open: http://localhost:3000--json prints { "up": ..., "procs": [...] }, or { "up": false, "reason": "no-pid-file" } when nothing is running.
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. Runs bin/devserve in the smartchats source, so it needs a source checkout.
smartchats dev [-- <devserve-args>]Anything after -- goes to bin/devserve unchanged. It has two target modes:
--target | Notes |
|---|---|
surreal (default) | SurrealDB in a Docker container on port 8000, plus the local server and the Next.js dev server with hot reload |
aio | Runs bin/aio: the all-in-one Docker image. Add --rebuild to rebuild it |
Other devserve flags: --port=<n> (Next.js port, default 3000), --no-server, --no-app, --no-prebuild, --no-surreal, --clean. Run bin/devserve --help for details.
smartchats dev -- --target=aio --rebuildSee Contributing for the development workflow.
smartchats upgrade
Upgrades a binary install by re-running the installer in place. Your data directory, .env and config.json are kept.
smartchats upgrade [options]| Flag | Default | Notes |
|---|---|---|
--version <tag> | latest | Install a specific release, for example v0.4.0 |
-y, --yes | off | Skip the confirmation prompt |
It runs curl -fsSL https://smartchats.ai/install | bash -s -- --non-interactive --version <tag> --prefix <install-root>. Run smartchats restart afterwards to use the new binaries.
For an npm install it prints npm install -g smartchats-ai@latest and exits 1. For a source checkout it tells you to git pull and exits 1.
Devices
The computer running SmartChats needs no pairing. A phone or another computer shows Pair this device and asks for a code. See Security.
smartchats pair
Prints a 6-digit code for one device, valid 5 minutes.
smartchats pair [--json] [--port <n>]
# Pairing code: 482 913 (valid 5 min, one device)
docker exec smartchats smartchats pair # Docker--json prints {"code": "482913", "expires_at": 1760000000000}.
smartchats devices
smartchats devices [--json] # id, name, paired, last used
smartchats devices revoke <id> # the device must pair againCloud
smartchats login
Browser sign-in to the SmartChats cloud. Clears any cached token first, then caches the new credentials at ~/.smartchats-mcp/credentials.json, the same file the MCP server reads.
smartchats loginsmartchats logout
Clears cached cloud credentials.
smartchats logoutsmartchats whoami
Shows the signed-in cloud user (uid, email, project, credentials file). If no credentials are cached, it starts the browser sign-in.
smartchats whoamismartchats data
Moves user data between deployments as a JSON bundle. Use it for backups, debugging, and moving between local and cloud.
smartchats data export <file> [options]
smartchats data import <file> [options]| Flag | Default | Notes |
|---|---|---|
--target=<cloud|local> | local | cloud uses your smartchats login credentials. local connects to ws://localhost:8000/rpc as root |
--file=<path> | none | Bundle path. The first positional argument works too |
--tables=t1,t2 | see below | Export: tables to export. Import: subset of the bundle’s tables to write |
--include-sensitive | off | Export only: also export byo_api_keys and usage_records |
--page-size=<n> | 100 | Export only: rows per page |
--dry-run | off | Import only: read and count rows, don’t write |
Each flag also accepts a space instead of = (for example --target cloud).
Without --tables, export writes logs, metrics, user_entities, user_relations, user_data, app_data, sessions, cortex, cortex_dynamic_functions, smartchats_apps and smartchats_app_installs. Telemetry tables are never exported. The bundle file is written with 0600 permissions.
Import upserts every row by id, so it’s safe to re-run. Rows are written as the user of the target deployment.
smartchats data export ~/backup.json --target=cloud
smartchats data import ~/backup.json --target=local --dry-run
smartchats data import ~/backup.json --target=cloud --tables=logs,metrics--target=local always uses port 8000. If you started the stack with a different --surreal-port, the local target can’t reach it.
Meta
smartchats doctor
Environment health check. Diagnoses what’s installed, what’s running, and what’s reachable.
smartchats doctor [--port <n>] [--json]| Flag | Default | Notes |
|---|---|---|
--port <n> | 3000 | Port to probe for the running stack |
--json | off | Print the full result set as JSON |
Checks (in order):
- SmartChats context: where is the source root?
- bun installed: critical.
- surreal installed: critical.
- Free disk ≥ 3 GB: warning only.
- Docker installed: informational.
- Image
smartchats-aio:latestpresent: informational. - Container
smartchatsrunning: informational. http://localhost:<port>responds: critical when thesmartchatscontainer is running.- Response is SmartChats: sanity check (catches port collisions).
- LLM provider keys: warning if no OpenAI, Anthropic or Google key is found.
Exits 0 if every critical check passes, 1 otherwise.
doctor looks for bun and surreal on PATH, even in a binary install. A binary install doesn’t need a separate bun, so this check can fail on a working install. doctor also reads .env from the source root only, so use smartchats env --list to check keys in a binary install.
smartchats home
Prints where smartchats lives and how the CLI found it.
smartchats home [--path-only]In a binary install it prints the install root and the server, surreal and SPA paths. --path-only prints just one path (the install root in a binary install, otherwise the source root), or exits 1 with no output if neither is found:
cd "$(smartchats home --path-only)"Source root resolution order: $SMARTCHATS_HOME → walking up from the current directory looking for Dockerfile.aio → config.smartchatsHome (written after an auto-clone).
smartchats help <command>
Per-command help. Same as <command> --help.
Legacy
smartchats launch
Hidden from --help but still callable. Builds and runs the Docker all-in-one image (smartchats-aio:latest) from the smartchats source, cloning it first if needed. Use smartchats start for new installs.
smartchats launch [options]Flags: --no-prompt, --rebuild, -d, --detached, --port <n>, --data-dir <path>, --tag <tag>, --test, --repo-path <path>. Run smartchats launch --help for details.
Environment
| Variable | Default | Purpose |
|---|---|---|
SMARTCHATS_HOME | unset | Path to a smartchats source checkout. Overrides the directory walk and config fallback |
SMARTCHATS_CONFIG_FILE | unset | Full path to the CLI config file |
XDG_CONFIG_HOME | unset | If set, CLI config lives at $XDG_CONFIG_HOME/smartchats/config.json (else ~/.smartchats/config.json) |
XDG_DATA_HOME | unset | If set, auto-clones go to $XDG_DATA_HOME/smartchats/cli/source |
SMARTCHATS_REPO_URL | https://github.com/sheunaluko/smartchats.git | Source URL for the auto-clone |
SMARTCHATS_CREDENTIALS_FILE | ~/.smartchats-mcp/credentials.json | Cloud credentials location |
SMARTCHATS_API_KEY | unset | Bearer token the server accepts from scripts and agents on other machines (Security) |
SMARTCHATS_AUTH | pair | off: no pairing, every device gets in |
SMARTCHATS_LOCAL_HOST | 127.0.0.1 | Dev mode only: host the Next.js /local-api/* rewrite forwards to |
SMARTCHATS_LOCAL_PORT | 4242 | Dev mode only: port for that rewrite |
NO_COLOR | unset | Disables CLI color output |
Provider keys are read from your environment and the .env file. A shell variable wins over .env. For each provider, the first name set wins, in this order:
| Provider | Names |
|---|---|
| OpenAI | SMARTCHATS_OPENAI_API_KEY, OPENAI_API_KEY |
| Anthropic | SMARTCHATS_ANTHROPIC_API_KEY, ANTHROPIC_API_KEY |
| Google (Gemini) | SMARTCHATS_GOOGLE_API_KEY, GOOGLE_API_KEY, GEMINI_API_KEY |
| xAI | SMARTCHATS_XAI_API_KEY, XAI_API_KEY |
| Together AI | SMARTCHATS_TOGETHER_API_KEY, TOGETHER_API_KEY, TOGETHERAI_API_KEY |
| Azure Speech | SMARTCHATS_AZURE_SPEECH_KEY, AZURE_SPEECH_KEY (plus SMARTCHATS_AZURE_SPEECH_REGION, AZURE_SPEECH_REGION) |
| Serper | SMARTCHATS_SERPER_API_KEY, SERPER_API_KEY |
The CLI prompts for the OpenAI, Anthropic, Google and Serper keys. The server reads all of them. See Self-Hosting for server settings.
Files
| Path | Purpose |
|---|---|
~/.smartchats/bin/ | Installed binaries |
~/.smartchats/app/out/ | Static SPA bundle |
~/.smartchats/data/surreal.db | 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/.env | Provider keys and config, binary install |
<repo>/.env | Provider keys and config, source or npm install |
~/.smartchats/cli/source/ | Default auto-clone location when no source is found |
~/.smartchats-mcp/credentials.json | Cloud credentials, shared with the MCP server |
See also
- Quick Start: install and 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.