@token2chat/t2c
v0.2.0-beta.1
Published
t2c - Pay-per-request LLM access via Cashu ecash
Downloads
147
Maintainers
Readme
t2c - Token2Chat CLI
Pay-per-request LLM access via Cashu ecash.
Installation
npm install -g @token2chat/cliQuick Start
# 1. Run setup wizard
t2c setup
# 2. Start the proxy service
t2c service start
# 3. Add funds to your wallet
t2c mint
# 4. Configure your AI tool
t2c config openclaw --apply # For OpenClaw (auto-merge)
t2c config cursor # For Cursor
t2c config env # For other tools
# 5. (Optional) Install as system service for auto-start
t2c service installCommands
t2c setup
Interactive setup wizard. Configures Gate URL, Mint URL, proxy port, and wallet path.
t2c status
Show service status and wallet balance.
t2c status # Pretty output
t2c status --json # JSON outputt2c service
Manage the local proxy service.
t2c service start # Start as daemon
t2c service start -f # Run in foreground
t2c service stop # Stop the service
t2c service restart # Restart the service
t2c service status # Show detailed service status
t2c service logs # Show logs
t2c service logs -f # Follow logs
# System service management (auto-start on login)
t2c service install # Install as launchd (macOS) or systemd (Linux)
t2c service uninstall # Uninstall system servicet2c mint
Add funds to your wallet.
t2c mint # Show deposit address
t2c mint --check # Check for pending deposits
t2c mint 1000 # Create Lightning invoice for 1000 satt2c config
Generate configuration for AI tools.
t2c config list # List supported tools
t2c config openclaw # Show OpenClaw config
t2c config openclaw --apply # Apply to openclaw.json (creates backup)
t2c config openclaw --json # Output raw JSON
t2c config cursor # Show Cursor config
t2c config env # Show environment variablesArchitecture
┌─────────────┐ ┌──────────────────┐ ┌──────────┐
│ AI Tool │────▶│ t2c proxy │────▶│ Gate │
│ (OpenClaw, │ │ :10402 (ecash) │ │ │
│ Cursor, │ └──────────────────┘ └──────────┘
│ etc.) │
└─────────────┘The proxy:
- Receives OpenAI-compatible requests from AI tools
- Selects ecash tokens from your local wallet
- Forwards requests to the Gate with payment
- Handles change/refund tokens automatically
- Returns the LLM response to your AI tool
Configuration
Config is stored in ~/.t2c/config.json:
{
"gateUrl": "https://gate.token2chat.com",
"mintUrl": "https://mint.token2chat.com",
"walletPath": "~/.t2c/wallet.json",
"proxyPort": 10402,
"lowBalanceThreshold": 1000
}System Service
macOS (launchd)
# Install
t2c service install
# Load manually
launchctl load ~/Library/LaunchAgents/com.token2chat.proxy.plist
# Uninstall
t2c service uninstallLinux (systemd)
# Install
t2c service install
# Enable and start
systemctl --user daemon-reload
systemctl --user enable t2c-proxy.service
systemctl --user start t2c-proxy.service
# Uninstall
t2c service uninstallSupported AI Tools
| Tool | Command | Notes |
|------|---------|-------|
| OpenClaw | t2c config openclaw --apply | Auto-merges token2chat provider |
| Cursor | t2c config cursor | OpenAI base URL config |
| Generic | t2c config env | OPENAI_API_KEY + OPENAI_BASE_URL |
Any tool that supports OpenAI-compatible APIs can use Token2Chat.
Error Handling
The CLI handles various error conditions gracefully:
- No config: Prompts to run
t2c setup - No wallet: Creates one automatically
- Corrupted config: Auto-recovers with backup
- Network timeout: Retries with exponential backoff
- Insufficient balance: Clear error message with balance info
Development
# Clone and install
git clone https://github.com/token2chat/cli.git
cd cli
npm install
# Build
npm run build
# Run tests
npm test
# Run with coverage
npm run test:coverage
# Link for local testing
npm linkLicense
MIT
