tf-cli
tf-cli provides the tf command to store TokenFlux API keys, select models, and launch Claude Code, Codex, OpenCode, or Pi. It is not a standalone chat client; the launched client handles conversations.
Use tf to manage multiple keys from the terminal or preserve your clients' existing global configurations. For graphical provider configuration, see CC-Switch.
Installation
Choose one installation method.
Requires Node.js 18 or later:
npm install -g @tokenflux/tfThe official npm package is @tokenflux/tf. The unscoped tf and tf-cli packages are unrelated projects. Platform binaries are distributed through optional dependencies; do not use --omit=optional or --no-optional.
Check that the command is available:
tf version
tf --helpImport a TokenFlux API Key
Prepare a key using Create API Key. Confirm that its group allows the target client and protocol, and that the account has available inference credits.
tf login- Choose "Import from web", then select the default TokenFlux gateway.
- Use the Keys page opened by the terminal, select the key, and complete the web import operation.
- Return to the terminal, check the origin, gateway, group, and masked key, then confirm to save.
- If you did not specify a local name, choose automatic naming, the web key name, or a custom name when prompted.
Do not share the full web link opened by the terminal. It contains verification information for this import session. If the page or terminal reports an unverified session, cancel and reopen the link generated by tf login. The key is saved only after you confirm in the terminal.
If your browser fails to open automatically, use hidden input instead:
tf login --with-keySelect the TokenFlux gateway and paste the key when prompted. Do not pass a real key as a command-line argument.
To assign a fixed local name, such as work:
tf login workwork is a local alias, not a platform group name. Replacing a different key under an existing name requires confirmation and defaults to cancellation.
Launch a Client
Run the command for your client:
| Client | Launch command |
|---|---|
| Claude Code | tf claude |
| Codex | tf codex |
| OpenCode | tf opencode |
| Pi | tf pi |
On first launch, follow the prompts to choose a key, main model, and required auxiliary models. Default bindings and model settings are saved in tf's own configuration. If the client is not installed, interactive mode offers installation options and installs only after confirmation.
In the client, start a new conversation and send "Reply with OK only". This makes a real model call and incurs charges. After receiving a text response, check the key, model, and charge in the usage logs. Successful installation, key import, or listing models alone does not prove that inference works.
Temporary Overrides and Default Models
For This Launch Only
tf claude -m
tf codex -k work
tf codex -e high-m without a value opens the model picker; -k work selects a locally stored key; -e high sets reasoning effort for this launch, subject to model and client support. These flags do not change saved default bindings or slots.
Put underlying client arguments after --, for example to resume a Claude Code session:
tf claude -- --resumetf codex --help shows Codex's own help. Use tf --help codex for the tf wrapper's options.
Change Models for Future Launches
Inspect the Codex model assignment or open its editor:
tf model codex
tf model codex --editModel slots assign models to different tasks in a client:
| Client | Model slots |
|---|---|
| Claude Code | default main conversation, fast background tasks, heavy high-compute tier |
| Codex | default main conversation, review code review |
| OpenCode | default main model, small lightweight tasks |
| Pi | default main conversation |
You can also set a slot directly. Replace MODEL_ID with a full model ID supported by the current key; preserve the group prefix for a composite key:
tf model codex --set default=MODEL_IDChanging keys affects the availability of selected models. Before clearing affected slots, the editor lists the changes and asks for confirmation.
Configuration Boundaries and Credential Storage
tf injects gateway configuration through child-process environments and launch arguments without rewriting clients' global configuration files. Running codex, claude, or another client directly does not use the tf binding. Clients can still save their own sessions or settings; tf does not sandbox them.
Run tf config to locate configuration and credentials. The default configuration directory is ~/.tf; when using XDG paths, follow the actual command output. API keys are stored in plaintext in credentials.json, protected by 0600 permissions on Unix or an access control list on Windows. This is not encryption at rest. Do not publish or sync that file.
If other configuration tools have already written settings, run tf status to inspect conflicts. For example, env in ~/.claude/settings.json can override process injection. Back up the file and inspect the reported fields instead of deleting the entire configuration.
Troubleshooting and Removing Keys
tf status
tf keys
tf keys --refreshtf status shows saved accounts' usage, model bindings, and environment conflicts. tf keys lists local keys and their eligible clients. After group or model changes, use tf keys --refresh to refresh the catalog and protocol probes.
If candidate models are hidden, check the protocol or client restrictions reported in the terminal. tf does not bypass group restrictions; switch to a group that supports your target client rather than merely changing the Base URL. For actual request errors, see Troubleshooting.
Remove the locally stored work key:
tf logout workThis does not revoke the key on TokenFlux. If it has leaked, also disable the old key on the API keys page.
Updating and Uninstalling
For npm installations, update with npm:
npm install -g @tokenflux/tf@latestWhen no longer needed, uninstall the npm package:
npm uninstall -g @tokenflux/tfStandalone binary installations can check with tf update --check and upgrade with tf update. For script-based uninstallation, see the project README. Uninstalling preserves local credentials and configuration by default; confirm whether you still need them before removing them.