A simple utility to update the USAi API key for OpenCode installations.
curl -fsSL https://raw.githubusercontent.com/underwoo/opencode-key-updater/main/install.sh | bashAfter installation, update your API key with:
install-key <your-new-api-key>install-key api-key-89bb4500-5704-41b9-97f4-ea8c33b25ff9:B7N8SoTYDKPP9CS8cHCXg4izixL2o6HE- ✅ Simple: Single command to update your API key
- ✅ Safe: Automatic backups before making changes
- ✅ Smart: Auto-restores on failure
- ✅ Clear: Color-coded output and helpful messages
- ✅ Targeted: Only updates the USAi provider key
The install-key command:
- Creates a timestamped backup of your OpenCode auth file
- Updates only the USAi provider's API key
- Preserves all other provider credentials
- Shows clear success/failure messages
- Provides restore instructions if needed
- macOS or Linux
- Python 3 (typically pre-installed)
- OpenCode installed and configured
If you prefer not to use the curl installer:
# Download the script
curl -fsSL https://raw.githubusercontent.com/underwoo/opencode-key-updater/main/install-key -o ~/.local/bin/install-key
# Make it executable
chmod +x ~/.local/bin/install-key
# Ensure ~/.local/bin is in your PATH
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshenv # or ~/.bashrc
source ~/.zshenv # or source ~/.bashrcMake sure ~/.local/bin is in your PATH:
# For zsh (macOS default):
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshenv
source ~/.zshenv
# For bash:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcOr use the full path:
~/.local/bin/install-key <your-api-key>Ensure OpenCode is installed and you've run it at least once to create the configuration files.
If you need to restore an old key, backups are stored at:
~/.local/share/opencode/auth.json.backup.YYYYMMDD_HHMMSS
Restore with:
cp ~/.local/share/opencode/auth.json.backup.YYYYMMDD_HHMMSS ~/.local/share/opencode/auth.jsonAfter updating your key, verify the change:
opencode providers listMIT
Issues and pull requests welcome at: https://github.com/underwoo/opencode-key-updater