droid-switch
v1.3.1
Published
A tool for switching between Factory API keys
Maintainers
Readme
Droid Switch
A command-line tool for switching between Factory API keys.
Commands
ds list- List all keys with usage information and switch interactivelyds current- Show the currently active key with its usageds add- Add API keys interactively (enter keys separated by spaces)ds del- Delete API keys interactively (supports multi-selection)ds- Show help information
Installation
npm install -g droid-switchPrerequisites
Before using this tool, you need to create a ~/.factory/keys.json file with your API keys:
[
"fk-xxxxxxxxx",
"fk-yyyyyyyyy"
]Usage
List and Select Keys
Run ds list to interactively select and switch between keys:
ds listThis command will:
- Fetch the latest usage information for all keys
- Show a list of your keys with their usage information (总量/剩余)
- Allow you to select one using arrow keys
- Update the environment variable in ~/.zshrc after selection
Show Current Key
Display the currently active key:
ds currentAdd New Keys
Add API keys to your key list interactively:
ds addWhen prompted, you can:
- Enter a single key:
fk-xxxxxxxxx - Enter multiple keys separated by spaces:
fk-xxxxxxxxx fk-yyyyyyyyy fk-zzzzzzzzz
The command will:
- Prompt you to enter API keys
- Accept multiple keys separated by spaces in a single input
- Validate that keys start with "fk-"
- Skip duplicate keys if they already exist
- Display the number of keys successfully added
Delete Keys
Interactively delete keys from your list:
ds delThis command will:
- Show all your keys in an interactive checkbox list
- Allow you to select multiple keys using the space bar
- Protect the currently active key from deletion (shown as disabled)
- Ask for confirmation before deleting selected keys
- Ensure you always have at least one working key
Features
- 🔑 Interactive key selection with arrow keys
- 📊 Real-time usage statistics (total and remaining tokens)
- ✅ Visual indicator for the currently active key
- 🔒 Secure key masking (shows only partial key)
- 💾 Automatic environment variable configuration in
~/.zshrc - 📋 v1.2.0: Automatically copies
source ~/.zshrccommand to clipboard - ⌨️ NEW v1.3.0: Pre-fills
source ~/.zshrccommand in terminal - just press Enter!
Note
Auto-fill Command (v1.3.0+) - Recommended
After switching keys with ds list:
- The
source ~/.zshrccommand is automatically typed in your terminal - Just press Enter to execute - that's it!
- The command is also copied to clipboard as backup
Clipboard Method (v1.2.0+)
If auto-fill doesn't work in your terminal:
- The command is copied to your clipboard
- Paste it (Cmd+V on Mac, Ctrl+V on Linux/Windows)
- Press Enter to execute
Manual Method
If both auto features fail:
source ~/.zshrcOr simply open a new terminal window for the changes to take effect.
