Claude Code One-Click Install Script
If you've already purchased quota, you can use the one-click script directly. Just change API_KEY in the script to your own key and run it.
Usage
bash
chmod +x claudecode.sh
./claudecode.shFull Script
bash
#!/bin/bash
# ==============================================================================
# Configuration section - set your API configuration here
# ==============================================================================
readonly API_KEY=""
readonly API_BASE_URL="https://api.nexthub.cc"
# Do not modify the content below
readonly CLAUDE_COMMAND="claude"
readonly NPM_PACKAGE="@anthropic-ai/claude-code"
readonly CLAUDE_DIR="$HOME/.claude"
readonly SETTINGS_FILE="$CLAUDE_DIR/settings.json"
detect_os() {
case "$(uname -s)" in
Darwin) echo "macos" ;;
Linux) echo "linux" ;;
*) echo "unknown" ;;
esac
}
check_config() {
if [ -z "$API_KEY" ] || [ -z "$API_BASE_URL" ]; then
echo "Configuration is incomplete. Please fill in API_KEY and API_BASE_URL"
exit 1
fi
}
install_homebrew() {
if ! command -v brew > /dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}
install_macos_packages() {
install_homebrew
command -v node > /dev/null || brew install node
command -v jq > /dev/null || brew install jq
command -v python3 > /dev/null || brew install python3
}
install_linux_packages() {
if command -v apt-get > /dev/null; then
sudo apt-get update
command -v node > /dev/null || { curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt-get install -y nodejs; }
command -v jq > /dev/null || sudo apt-get install -y jq
command -v python3 > /dev/null || sudo apt-get install -y python3 python3-pip
fi
}
install_claude_code() {
command -v "$CLAUDE_COMMAND" > /dev/null && return
# Install without sudo first; retry with sudo only if you hit the common EACCES permission error with system-level Node on Linux
npm install -g "$NPM_PACKAGE" || sudo npm install -g "$NPM_PACKAGE"
}
configure_claude_code() {
mkdir -p "$CLAUDE_DIR"
cat > "$SETTINGS_FILE" << EOF
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "$API_KEY",
"ANTHROPIC_BASE_URL": "$API_BASE_URL",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
EOF
}
main() {
check_config
OS=$(detect_os)
case "$OS" in
macos) install_macos_packages ;;
linux) install_linux_packages ;;
*) echo "Unsupported operating system"; exit 1 ;;
esac
install_claude_code
configure_claude_code
echo "Installation complete. You can now run claude!"
}
main "$@"Usage Notes
The script automatically installs dependencies like Node.js, jq, and Python3, and creates or overwrites ~/.claude/settings.json (back up your existing configuration first). The written ANTHROPIC_BASE_URL is https://api.nexthub.cc without a /v1 suffix. On Linux, if a global install hits a permission error (EACCES), the script automatically retries with sudo.
Ready to Get Started?
Sign up for NextHub and start experiencing a highly stable, cost-effective AI model API service right away.