Docs

CLI reference

Usage

text
tokmine [start] [flags]    discover local models and open the tunnel (default)
tokmine upstream            connect OpenAI, Anthropic, ... to your endpoints and set the fallback order
tokmine install [runner]   install a local model server and a model (ollama, llamacpp)
tokmine login [--token T]  store an agent token (or set TOKMINE_TOKEN)
tokmine endpoints          list your endpoints and their machines
tokmine provider           save URL-based providers (OmniRoute, LiteLLM, ...): add, list, remove, detect
tokmine privacy            audit local runtimes for prompt logging
tokmine privacy apply      fix what the audit found, asking first (--yes, --dry-run)
tokmine client             point AI clients at your endpoint
tokmine update             update to the latest release
tokmine logout             remove the stored token
tokmine status             show configuration, providers and reachability
tokmine models             list discovered models
tokmine version

tm is an alias for tokmine and takes the same arguments.

Commands

CommandDescription
tokmine [start]Default. Discover local model servers, open the tunnel, print the public URL and stay running.
tokmine install [runner|family]Install a local model server (ollama by default, or llamacpp) and pull a model that fits this machine. Families such as glm or qwen pick a model from that family. Options below. See Install a local model.
tokmine login [--token T]Store your agent token in the config file. Without --token it reads TOKMINE_TOKEN, then prompts. Also saves --name, --endpoint and --server if given.
tokmine endpointsList your workspace's endpoints: name, slug, public URL and machines online/total. Needs a logged-in machine. See Static endpoints.
tokmine logoutRemove the stored token. The machine id is kept.
tokmine statusShow version, mode (anonymous or authenticated), machine name and id, endpoint and whether it is reachable, config path, and discovered providers.
tokmine modelsOne-off scan: list discovered providers, dialects and models.
tokmine privacyAudit local runtimes for prompt logging and print the privacy tier the marketplace uses, with fix hints. --json for machine-readable output. See Privacy checks.
tokmine privacy applyFix what tokmine privacy found, asking before each change: turn off Ollama debug logging (systemd override, macOS launchctl or Windows user variable), switch off LM Studio's prompt logging (close LM Studio first) and delete its saved chats and the server logs that hold earlier prompts. A .tokmine-bak copy is kept for edited files. --yes approves the changes that do not delete anything; deleting also needs --allow-delete. --dry-run shows the changes only, --only ollama:debug-on picks a fix. Runtimes configured in your own scripts or containers are listed as manual steps.
tokmine upstreamConnect OpenAI, Anthropic, Gemini, OpenRouter and other public services to your endpoints and choose the fallback order. See Managed router.
tokmine providerSave URL-based providers such as OmniRoute, LiteLLM, OpenRouter or any OpenAI-compatible URL, with their headers. Subcommands add, list, remove and detect; options below. See URL-based providers.
tokmine updateUpdate to the latest release (checksum verified). --check only reports, --version X.Y.Z picks a version, --force reinstalls even when up to date. Available from 0.5.0; older versions re-run the install command once.
tokmine clientPoint AI tools at your endpoint. Plain tokmine client configures OpenCode and Codex (asks first, keeps a backup) and lists the rest; client list shows every supported tool; client show <id> prints exact steps (Cursor, Devin, Antigravity, ...). --models 'qwen*,*claude*' and --no-variants trim long model lists; --print opencode prints the OpenCode config as one env var. Needs tokmine login. See AI tools and clients.
tokmine serviceRun tokmine in the background, started at login and restarted if it crashes. Subcommands install, uninstall and status; see Run in the background.
tokmine versionPrint version, commit, build date and OS/arch.
tokmine helpPrint usage.

Flags

For start, status and models:

FlagDescription
--name <name>Machine name. Defaults to the hostname.
--provider <url>Add a model server manually (for example http://gpu-box:8000). Repeatable. See runners.
--dialect <d>Force the dialect of --provider servers: openai, anthropic, gemini or ollama.
--endpoint <slug>, -eJoin this endpoint (a static endpoint of your workspace, or default). Authenticated machines only. Without it the CLI auto-selects your only static endpoint, asks you to choose among several, or uses the default endpoint. See Static endpoints.
--server <url>Override the Tokmine server (default https://tunnel.tokmine.ai). For development. This was --endpoint <url> in earlier versions; a URL passed to --endpoint or TOKMINE_ENDPOINT still works as the server but prints a deprecation notice.
--app-url <url>Web portal used for the chat link (default https://app.tokmine.ai). See Browser chat.
--no-discoverSkip probing the well-known local ports. Only --provider servers are used.
--jsonEmit machine-readable events, one JSON object per line.
--verboseMore output. Tokens are never logged.
--token <t>Agent token (login).

Flags for install

FlagDescription
--model <name>Pull this model instead of choosing one from RAM and GPU.
--method <m>auto (default), script, brew, winget or docker.
--yesSkip confirmation prompts, including before running an installer script.
--dry-runShow the plan and change nothing.
Without a terminal, --yes is required. Details in Install a local model.

Flags for provider

FlagDescription
add <url>Probe and save an OpenAI-compatible base URL, for example http://localhost:20128/v1. A trailing /v1 is optional.
--preset <p>omniroute (http://localhost:20128/v1), litellm (http://localhost:4000/v1) or openrouter (needs a key). Fills in the URL and name.
--name <n>Label shown in status and models. Saving the same name again updates it.
--api-key-env <VAR>Send Authorization: Bearer $VAR, read from the environment at run time. The secret is never written to the config file.
--api-key <key>Same, but stores the key in the config file (owner-only permissions).
--header "Name: value"Extra header sent to the provider. Repeatable. Values may use ${ENV_VAR}.
--dialect <d>openai, anthropic, gemini or ollama. Default: detect.
--no-checkSave without probing the URL.
list, remove <name|url>Show saved providers (header names only, never values) or delete one.
detectProbe the common ports and report what is running, and which gateways (OmniRoute, LiteLLM, Xinference) answer but need an API key.

Flags for upstream

Needs tokmine login. The Tokmine server calls these services, so nothing has to keep running on this machine. Writes need a workspace admin on a paid plan.

Command or flagDescription
list (--json)Connected services with status, the key's last four characters and your usage against the limit.
add <kind>openai, anthropic, gemini, openrouter, omniroute, litellm or custom. The server checks the key and reports the models found.
--name <n>, --models a,bLabel (default: the kind), and an optional allow-list of models to offer from the service.
--url <u>Base URL, required for omniroute, litellm and custom. Public https, without /v1.
--key-env <VAR>, --key-stdinWhere the API key comes from. Default: $OPENAI_API_KEY, $ANTHROPIC_API_KEY, $GEMINI_API_KEY or $OPENROUTER_API_KEY by kind. Keys are never accepted as flag values.
test, enable, disable, key, remove <service>By name, id or unique id prefix. key replaces the stored key and tests it; remove erases it.
route <endpoint> [hop ...]Show or set the order requests try: machines, a service name, marketplace. --default restores machines then marketplace. Named endpoints only.

Environment variables

Precedence is flags, then environment, then the config file.

TOKMINE_TOKENAgent token. Alternative to tokmine login.
TOKMINE_NAMEMachine name.
TOKMINE_PROVIDERSComma or space separated provider URLs.
TOKMINE_DIALECTForced dialect for manual providers.
TOKMINE_ENDPOINTEndpoint slug to join, same as --endpoint.
TOKMINE_SERVERTokmine server URL override (formerly TOKMINE_ENDPOINT).
TOKMINE_APP_URLWeb portal URL for the chat link. Can also be set as appUrl in the config file.
TOKMINE_CONFIG_DIRDirectory for the config and session files.
OLLAMA_HOSTHonoured during discovery.
NO_COLORDisable coloured output.
HTTPS_PROXY, HTTP_PROXYStandard proxy settings.

Config file

Location: ~/.config/tokmine/config.json on Linux and macOS (or $XDG_CONFIG_HOME/tokmine), %APPDATA%\tokmine\config.json on Windows, or $TOKMINE_CONFIG_DIR/config.json. It is written atomically with owner-only permissions.

json
{
  "token": "<agent-token>",
  "machineId": "3f0c...",
  "name": "gpu-box-1",
  "endpoint": "acme-prod",
  "server": "https://tunnel.tokmine.ai",
  "appUrl": "https://app.tokmine.ai",
  "providers": ["http://gpu-box:8000"],
  "dialect": "openai",
  "upstreams": [
    {
      "name": "OmniRoute",
      "url": "http://localhost:20128/v1",
      "headers": { "Authorization": "Bearer ${OMNIROUTE_KEY}" }
    }
  ]
}

machineId is generated on first run and identifies this machine across restarts. endpoint is the endpoint slug to join and server the Tokmine server URL (before this release, endpoint held the server URL). upstreams are the URL-based providers saved with tokmine provider add. An anonymous session is kept next to it in anon-session.json and deleted when it expires.

Behaviour

  • Reconnects automatically after network loss or sleep, with exponential backoff and jitter (1 to 30 seconds). The delay resets once a connection is stable.
  • Fatal errors stop it rather than retrying: rejected agent token, plan limit reached, an endpoint that does not exist, was disabled or deleted, or needs a paid plan, an outdated CLI, or another process using the same machine id. The message says what to do.
  • Anonymous sessions resume across restarts and end after 30 minutes, when the CLI exits.
  • Prints a chat link once online (and when an anonymous session resumes), to try the endpoint in the browser. --json adds it to the online event as chatUrl. See Browser chat.
  • With no local model server (and no --provider), suggests tokmine install ollama and, in an interactive terminal, asks Install Ollama now? [y/N] before connecting. A server with no models gets a tokmine install --model hint.
  • Endpoints (logged-in machines): the CLI prints the endpoint name and public URL on start and in status. If the endpoint is deleted or disabled while it runs, or your plan no longer includes static endpoints, the CLI prints why, does not reconnect and exits with code 78; pick another with --endpoint. The chat link becomes https://app.tokmine.ai/chat?endpoint=<slug> (no token in it).
  • Reports CPU, RAM and GPU load so traffic can be balanced across machines.
  • Ctrl-C (or SIGTERM) drains in-flight requests before exiting.

Run in the background

tokmine service install makes tokmine start when you log in and restart it if it crashes. It uses what your system already has: a launchd agent on macOS, a systemd user unit on Linux and a Scheduled Task on Windows. It needs tokmine login first, because an anonymous session lasts 30 minutes. The token stays in the config file; it is never written into the service.

bash
tokmine login
tokmine service install --endpoint home --now
tokmine service status
tokmine service uninstall
Command or flagDescription
service installInstall the service. Asks first; --yes skips the question and --dry-run prints what would be installed and changes nothing. Without --now it starts at your next login.
--nowAlso start it right away. Do not use it while tokmine is already running in a terminal: two processes cannot share a machine id.
--name, --endpoint, --providerSame as for tokmine. Set --endpoint if you have several: a background service cannot ask.
--restart-delay <seconds>Wait before restarting after a crash. Default 30.
service statusShow whether it is installed and running, and where the log is.
service uninstallStop and remove it. Safe to run when nothing is installed.
  • Logs: ~/Library/Logs/tokmine/tokmine.log on macOS, ~/.local/state/tokmine/tokmine.log on Linux, %LOCALAPPDATA%\tokmine\tokmine.log on Windows.
  • Fatal errors are not retried. A rejected token, a reached plan limit or a deleted endpoint stops the service instead of restarting it in a loop; read the log, fix it, then start it again.
  • After tokmine update the service keeps running the old process. Run tokmine service install --now again to restart it on the new binary.
  • Linux servers: a user unit stops when you log out unless you run sudo loginctl enable-linger $USER. Without systemd, use your own supervisor.
  • macOS: a launch agent starts when you log in. A Mac mini that must come back after a power cut also needs automatic login turned on in System Settings.
  • Windows: the task runs at logon and is not restarted automatically after a crash.

Exit codes

0Normal exit (including Ctrl-C) or a successful command.
1Runtime error or a failed command.
78Fatal tunnel error that retrying cannot fix: bad token, plan limit, endpoint not found, disabled or not allowed, session refused. Service managers are told not to restart on it. Set TOKMINE_FATAL_EXIT_CODE to use another code.
2Invalid usage: unknown command, flag, dialect or provider URL, or several endpoints and none chosen in a non-interactive run.
Flags and commands may change until the first stable release.