docsCLI Reference

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 | bash

Top-level

smartchats <command> [options]

If you run smartchats with no arguments:

  • No config and no source reachable → runs setup (guided first run).
  • Otherwise → runs start on 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]
FlagDefaultNotes
--no-promptoffUse existing env / .env values. Skip all prompts
--no-startoffCollect config only. Don’t start the stack
--repo-path <path>~/.smartchats/cli/sourceWhere to clone the source (source and npm installs only)

What it walks through, in order:

  1. 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/source if that variable is set).
  2. System check: free disk (warns below 3 GB). Source and npm installs also need bun and surreal, and setup stops with an install command if either is missing.
  3. API keys: walks OpenAI, Anthropic, Google and Serper. For each, it shows what it found in your environment or .env and lets you keep or replace it.
  4. Write + start: writes .env and runs start. 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]
FlagDefaultNotes
-l, --listoffShow 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 install

To 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]
FlagDefaultNotes
--port <n>3000App port (browser connects here)
--surreal-port <n>8000SurrealDB port (binds to 127.0.0.1)
--data-dir <path>~/.smartchats/dataSurrealDB storage. The database is <data-dir>/surreal.db
--rebuildoffSource mode only: run the workspace build before starting. Ignored in a binary install
-f, --foregroundoffStay attached. Ctrl-C or SIGTERM stops both processes
--no-promptoffSkip 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>]
FlagDefaultNotes
--timeout <ms>5000How 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]
FlagDefaultNotes
-f, --followoffStream new output (Ctrl-C to stop)
--proc <surreal|server|all>allWhich process(es) to show
-n, --lines <n>50Initial 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:

--targetNotes
surreal (default)SurrealDB in a Docker container on port 8000, plus the local server and the Next.js dev server with hot reload
aioRuns 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 --rebuild

See 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]
FlagDefaultNotes
--version <tag>latestInstall a specific release, for example v0.4.0
-y, --yesoffSkip 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 again

Cloud

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 login

smartchats logout

Clears cached cloud credentials.

smartchats logout

smartchats whoami

Shows the signed-in cloud user (uid, email, project, credentials file). If no credentials are cached, it starts the browser sign-in.

smartchats whoami

smartchats 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]
FlagDefaultNotes
--target=<cloud|local>localcloud uses your smartchats login credentials. local connects to ws://localhost:8000/rpc as root
--file=<path>noneBundle path. The first positional argument works too
--tables=t1,t2see belowExport: tables to export. Import: subset of the bundle’s tables to write
--include-sensitiveoffExport only: also export byo_api_keys and usage_records
--page-size=<n>100Export only: rows per page
--dry-runoffImport 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]
FlagDefaultNotes
--port <n>3000Port to probe for the running stack
--jsonoffPrint the full result set as JSON

Checks (in order):

  1. SmartChats context: where is the source root?
  2. bun installed: critical.
  3. surreal installed: critical.
  4. Free disk ≥ 3 GB: warning only.
  5. Docker installed: informational.
  6. Image smartchats-aio:latest present: informational.
  7. Container smartchats running: informational.
  8. http://localhost:<port> responds: critical when the smartchats container is running.
  9. Response is SmartChats: sanity check (catches port collisions).
  10. 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

VariableDefaultPurpose
SMARTCHATS_HOMEunsetPath to a smartchats source checkout. Overrides the directory walk and config fallback
SMARTCHATS_CONFIG_FILEunsetFull path to the CLI config file
XDG_CONFIG_HOMEunsetIf set, CLI config lives at $XDG_CONFIG_HOME/smartchats/config.json (else ~/.smartchats/config.json)
XDG_DATA_HOMEunsetIf set, auto-clones go to $XDG_DATA_HOME/smartchats/cli/source
SMARTCHATS_REPO_URLhttps://github.com/sheunaluko/smartchats.gitSource URL for the auto-clone
SMARTCHATS_CREDENTIALS_FILE~/.smartchats-mcp/credentials.jsonCloud credentials location
SMARTCHATS_API_KEYunsetBearer token the server accepts from scripts and agents on other machines (Security)
SMARTCHATS_AUTHpairoff: no pairing, every device gets in
SMARTCHATS_LOCAL_HOST127.0.0.1Dev mode only: host the Next.js /local-api/* rewrite forwards to
SMARTCHATS_LOCAL_PORT4242Dev mode only: port for that rewrite
NO_COLORunsetDisables 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:

ProviderNames
OpenAISMARTCHATS_OPENAI_API_KEY, OPENAI_API_KEY
AnthropicSMARTCHATS_ANTHROPIC_API_KEY, ANTHROPIC_API_KEY
Google (Gemini)SMARTCHATS_GOOGLE_API_KEY, GOOGLE_API_KEY, GEMINI_API_KEY
xAISMARTCHATS_XAI_API_KEY, XAI_API_KEY
Together AISMARTCHATS_TOGETHER_API_KEY, TOGETHER_API_KEY, TOGETHERAI_API_KEY
Azure SpeechSMARTCHATS_AZURE_SPEECH_KEY, AZURE_SPEECH_KEY (plus SMARTCHATS_AZURE_SPEECH_REGION, AZURE_SPEECH_REGION)
SerperSMARTCHATS_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

PathPurpose
~/.smartchats/bin/Installed binaries
~/.smartchats/app/out/Static SPA bundle
~/.smartchats/data/surreal.dbSurrealDB rocksdb store
~/.smartchats/run/pids.jsonLive process state for the running stack
~/.smartchats/logs/{surreal,server}.logPer-process append logs
~/.smartchats/config.jsonCLI preferences (last port, resolved source root)
~/.smartchats/.envProvider keys and config, binary install
<repo>/.envProvider keys and config, source or npm install
~/.smartchats/cli/source/Default auto-clone location when no source is found
~/.smartchats-mcp/credentials.jsonCloud 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.