1.安装npm
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 22
# Verify the Node.js version:
node -v # Should print "v22.17.0".
nvm current # Should print "v22.17.0".
# Verify npm version:
npm -v # Should print "10.9.2".
2.设置terminal环境 使用API模式
# https://aistudio.google.com/app/apikey google账户Gemini api
echo 'export GEMINI_API_KEY="AIzaSyAO0qfzddYCzoPXdRdnXadsDEMP10cOXiw"' >> ~/.zshrc
source ~/.zshrc
3.安装Gemini CLI 并选择API模式
npm install -g @google/gemini-cli
gemini
4.运行
#terminal内之间执行
gemini