Skip to content

Typical Workflows

This guide covers the everyday workflows for tmf (TokenMofang) — browsing providers, switching between them, direct configuration for custom endpoints, saving reusable templates, testing connectivity, and rolling back when something goes wrong.

Workflow 1: Browse & Switch

Start by listing available providers, then switch one for your target application.

bash
# List all available providers
tmf list

# Example output:
# Available providers:
#   deepseek    (models: deepseek-chat, deepseek-reasoner)
#   openai      (models: gpt-4o, gpt-4o-mini)
#   claude      (models: claude-sonnet-4-20250514)

# Switch to the selected provider for Claude Code
tmf use deepseek --app claude-code

Workflow 2: Direct Configuration (set)

tmf set lets you configure any supported application with a custom API endpoint directly — no Provider API required. Ideal for self-hosted models, custom proxies, or providers not yet in the registry.

bash
# Point Claude Code at a self-hosted Ollama instance
tmf set claude-code --baseUrl https://ollama.local/v1 --key ollama

# Configure with model and save as a reusable template
tmf set opencode --baseUrl https://proxy.example.com/v1 --key sk-xxx \
  --model gpt-4o --save-as myproxy

The command auto-backs up the current config (.bak) so you can always roll back if needed.

Workflow 3: Save & Reuse Templates (save)

tmf save creates reusable parameter templates. Once saved, tmf use <name> picks up the template automatically — no need to re-enter URLs, keys, or models every time.

bash
# Save a template for a self-hosted Ollama instance
tmf save ollama --baseUrl http://localhost:11434/v1 --key ollama --model llama3

# Save a DeepSeek template with role-based models
tmf save deepseek --app claude-code --baseUrl https://api.deepseek.com/v1 --key sk-xxx \
  --models opus=deepseek-v4-pro,sonnet=deepseek-v4-pro,haiku=deepseek-v4-flash

# Apply the saved template — no need to re-specify parameters
tmf use deepseek

Templates are stored in ~/.tmf/templates/. CLI options (--key, --model, etc.) at use-time override template values.

Workflow 4: Switch & Test

After changing providers or models, it's good practice to verify connectivity immediately.

bash
# Switch to deepseek-chat model for Codex
tmf use deepseek --app codex --model deepseek-chat

# Test the connection
tmf test deepseek

If the test passes, the new configuration is active and ready to use.

Workflow 5: Rollback After Issues

If a switch causes problems, you can quickly restore the last stable configuration.

bash
# Roll back the specified application to its previous config
tmf rollback --app claude-code

Rollback restores from an automatically created backup — no manual file editing needed.

Configuration File Locations

tmf stores its configuration and backups in the following locations:

  • Global settings: ~/.tmf/config.json — contains API endpoints and other global configuration
  • Provider records: ~/.tmf/store/used.json — tracks which provider each application is currently using
  • Application config backups: .bak files are created alongside each application's configuration file when a switch is performed. They store the previous config so rollback can restore it.

Debugging

Append the --debug flag to any command to see detailed diagnostic information:

bash
# View detailed logs during a switch
tmf use deepseek --app claude-code --debug

# Inspect full request and response details during a test
tmf test deepseek --debug

--debug prints request URLs, headers, response data, and other key information — it's the first tool to reach for when troubleshooting configuration issues.

MIT License