Subscription Proxy (subs)
The optional subs part of the bundled tuse/default plugin wraps CLIProxyAPI so you can use existing AI subscriptions through a local loopback-only OpenAI-compatible proxy registered as a Tuse provider.
Loading or reloading "tuse/default" never installs software, creates config files, starts OAuth login flows, starts/probes background proxies, or modifies ~/.tuse/tuse.db. Every state-changing action requires explicitly running /subs and confirming the action.
Enabling subs
opts.subs defaults to false. Enable it with subs = true (all defaults) or an options table. Because opts.theme defaults to true, set theme = false explicitly for a subs-only setup:
return {
plugins = {
{
"tuse/default",
opts = {
theme = false,
subs = {
provider = "subs",
host = "127.0.0.1",
port = 8317,
config_dir = "~/.tuse/subs",
},
},
},
},
}
Options (opts.subs)
| Option | Type | Default | Meaning |
|---|---|---|---|
provider |
string | "subs" |
Tuse provider name registered with tuse connect / tuse disconnect. Must be non-empty and contain no / or whitespace. |
host |
string | "127.0.0.1" |
Loopback-only bind address. Must be "127.0.0.1", "::1", or "localhost"; non-loopback addresses (0.0.0.0, ::, LAN IPs) fail config validation. |
port |
integer | 8317 |
Local TCP port (1..=65535) for CLIProxyAPI. |
binary |
string | nil | nil |
Explicit path to cli-proxy-api. When unset, searches <config_dir>/bin/cli-proxy-api, then PATH. |
config_dir |
string | "~/.tuse/subs" |
Directory for generated CLIProxyAPI config, OAuth credentials, local bearer key, and optional installed binary. |
Unknown keys or invalid values fail config validation with a diagnostic naming plugin tuse/default and the full key path (for example plugin tuse/default: opts.subs.host: ...).
Pinned CLIProxyAPI Release & File Layout
subs pins CLIProxyAPI v8.1.2 (router-for-me/CLIProxyAPI) with hardcoded SHA-256 archive digests embedded in the bundled plugin:
| Platform | Archive | SHA-256 |
|---|---|---|
darwin/arm64 |
CLIProxyAPI_8.1.2_darwin_aarch64.tar.gz |
95d746c8d6cb418a88cb79937ca90194388faa707c30e3ec53e7d41f469cd6ec |
darwin/amd64 |
CLIProxyAPI_8.1.2_darwin_amd64.tar.gz |
3e4ae8dc26676ada1db8b5f8e95bf097670e7aefb0bf6c3f5a3340c00cb42f0e |
linux/arm64 |
CLIProxyAPI_8.1.2_linux_aarch64.tar.gz |
41245fa2af02d68c69376afc6360af49b58c3b2368d8cec1d61f0e43de14d580 |
linux/amd64 |
CLIProxyAPI_8.1.2_linux_amd64.tar.gz |
851e41c9a087b60e6586fec0c6be821b61921e8da0e84b9490ef542042db0756 |
Files and Permissions under <config_dir>
<config_dir>: mode0700<config_dir>/bin/cli-proxy-api: installed binary (when installed bysetup), mode0755<config_dir>/auth: OAuth credential directory, mode0700; files inside are tightened to mode0600after login<config_dir>/api.key: randomly generated 32-byte hex local bearer key, mode0600<config_dir>/config.yaml: mode0600, configuring loopbackhost,port,auth-dir,api-keys(the single local key), andremote-management: { allow-remote: false, disable-control-panel: true, secret-key: "" }
The /subs Command
When opts.subs is enabled, "tuse/default" registers one custom slash command /subs (callable from TUI /subs and JSON-RPC commands.run { "name": "subs" }). Invoking /subs opens a pick() menu with seven actions:
status— inspect binary, config, proxy process, endpoint health, and Tuse provider wiringsetup— locate or install CLIProxyAPI and create/reset local proxy configlogin— authenticate a subscription account with CLIProxyAPIstart— start the local CLIProxyAPI proxy as a managed session processstop— stop the proxy process started bysubsin this sessionconnect— verify and register (or atomically update) the running proxy as a Tuse provider and reloaddisconnect— verify ownership and remove thesubsprovider from Tuse and reload
Pressing Esc (or cancelling via ui.cancel) cancels with no side effects. All diagnostics render in the UI-only show("subs", ..., false) block after secret redaction.
setup
- Binary step: checks
opts.subs.binary,<config_dir>/bin/cli-proxy-api, andPATH. If missing, confirms viapick({"Install CLIProxyAPI v8.1.2", "Cancel"})before downloading into a staging folder under<config_dir>, verifying the SHA-256 digest against the hardcoded manifest (never trusting a remote checksum file), extractingcli-proxy-api, setting mode0755, and moving it atomically into<config_dir>/bin/cli-proxy-api. On mismatch or unsupported platform, removes staging files and suggestsopts.subs.binary. - Config step (confirmed even when the binary already exists):
- If
<config_dir>/config.yamlis missing: confirms viapick({"Create local config in <config_dir>", "Cancel"})before creating<config_dir>(0700),<config_dir>/auth(0700),<config_dir>/api.key(0600), and<config_dir>/config.yaml(0600). - If
<config_dir>/config.yamlexists: promptspick({"Keep existing config", "Reset config (rotates local API key)", "Cancel"}).
- If
- Shows next steps (
login->start->connect).
login
- Requires binary and
config.yamlto exist (otherwise points tosetup). - Prompts
pick({"OpenAI / Codex", "Anthropic / Claude", "Google / Gemini", "Cancel"}). - Runs
<binary> --config <config_dir>/config.yaml --no-browser <flag>directly (no shell interpolation, 5-minute timeout) using CLIProxyAPIv8.1.2flags:- OpenAI / Codex:
--codex-login - Anthropic / Claude:
--claude-login - Google / Gemini:
--antigravity-login
- OpenAI / Codex:
- Streams output incrementally while running: as soon as an
https://...authorization URL (and optional device code) appears, displays only the sanitized URL and instructions viashow("subs", ..., false)(clickable in TUI) before the process exits, never printing raw output or tokens. - Cancelling (Esc /
turn.cancel) or hitting the 5-minute timeout kills the login process group immediately. - On success, tightens permissions on files inside
<config_dir>/authto0600and reports completion.
start, stop, Ownership, and Reload Reconciliation
- Unforgeable ownership:
startspawns a managed background task (subs-proxy) and stores a session-scoped ownership record bound to the exacttask_idand{ host, port, config_dir, resolved_binary }.subsnever claims or stops a task by display name. start:- Requires binary and
config.yaml. - If the owned
task_idis already running and healthy, reports already running (idempotent). - Probes
http://<host>:<port>/v1/modelswith the local key: if HTTP 200 with valid JSON, reports an externally managed proxy without spawning a duplicate or recording ownership; if another unrelated service holds the port, reports a port conflict. - Runs
<binary> --config <config_dir>/config.yamldirectly (no secrets in argv), redacts every stdout/stderr line before writing to the task log, and returns only"subs-proxy stopped"or"subs-proxy exited with code N"so model task notifications never carry raw stderr or credentials. - Polls readiness for up to 10 seconds (failing fast if the task exits early). On failure, stops the task and clears ownership.
- Requires binary and
stop: stops only the ownedtask_id(killing its process group) and clears ownership. Never stops an externally managed proxy.- Session close: closing the session (
exit,/new,/resume,shutdown, signals) stops the owned proxy process group so nothing outlives the session. - Reload reconciliation:
- Failed
/reloadleaves the running proxy and ownership record untouched. - Successful
/reloadwith identical{ host, port, config_dir, resolved_binary }preserves the running proxy and transfers ownership without restarting. - Successful
/reloadthat removes/disablessubsor changeshost,port,config_dir, or resolvedbinarystops the previously owned task, clears ownership, and emits a notice (never auto-starting a new proxy).
- Failed
connect and disconnect
connect:- Probes
http://<host>:<port>/v1/modelswith<config_dir>/api.key; fails if the proxy is not running (never auto-starts). - Registers or updates
<provider>viatuse connect --base http://<host>:<port>/v1 --key-stdin --name <provider>(piping the key on stdin so it never appears in argv), adding--replacewhen<provider>already exists with the same URL (atomic verify-before-replace). If<provider>exists with a different URL, asks confirmation first. - Calls
reload()to activate the provider immediately in the session. Ifreload()fails (for example due to an unrelated config error), catches the error and reports that the provider was saved in~/.tuse/tuse.dband instructs the user to fix the config and run/reload.
- Probes
disconnect:- Idempotent when
<provider>is absent. - If
<provider>points to a different URL thanhttp://<host>:<port>/v1, requires confirmation before runningtuse disconnect <provider>. - Calls
reload()and reports partial state cleanly ifreload()fails.
- Idempotent when
Secret Redaction and status
All subs output — proxy task logs, task completion notifications, login output, status panels, and errors passed to show("subs", ...) — passes through a redactor that replaces the exact local api.key value, Authorization: Bearer ... headers, x-api-key / x-goog-api-key / api-key values, OAuth access_token / refresh_token / id_token / client_secret / cookie fields, OAuth code= query parameters, and JWT-shaped strings (eyJ...) with [REDACTED].
status reports binary path/version (compared against pinned v8.1.2), config and auth account presence (filenames/count only), proxy state (running (managed, task <id>), running (external), stopped, failed), endpoint health, Tuse provider wiring, and the redacted last error if any.