Created
August 22, 2025 22:51
-
-
Save gbrayut/d4ec0657406568d12c771bc4ae95c02e to your computer and use it in GitHub Desktop.
Gemini CLI instructions for Ubuntu Nobel 24.04.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install Gemini CLI https://github.com/google-gemini/gemini-cli | |
| apt-cache policy nodejs | |
| # if distro is using node < 20 then manage versions using nvm instead https://github.com/nvm-sh/nvm/tree/master | |
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash | |
| # open new shell or copy/paste export/load commands | |
| nvm install 22 # current LTS from https://nodejs.org/en/about/previous-releases | |
| npm install -g @google/gemini-cli | |
| # API keys not working in gemini-cli >= 0.1.15 https://aistudio.google.com/u/0/apikey | |
| #export GEMINI_API_KEY="AIzaSyCRSFCdFFn8G_REDACTED-..." # gregbray-vpc | |
| # instead use GCP api key from GSA https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys | |
| # Note: this same option should work for Claude Code https://docs.anthropic.com/en/docs/claude-code/google-vertex-ai | |
| gcloud iam service-accounts create gemini-cli --project=gregbray-vpc \ | |
| --description="Exported Service Account for gemini-cli" | |
| gcloud projects add-iam-policy-binding gregbray-vpc \ | |
| --member="serviceAccount:[email protected]" \ | |
| --role=roles/aiplatform.expressUser --condition None | |
| gcloud services api-keys create --display-name="Gemini CLI" --key-id=gemini-cli \ | |
| --service-account=gemini-cli@gregbray-vpc.iam.gserviceaccount.com \ | |
| --project gregbray-vpc | |
| # Edit your .bashrc to look something like this (replacing the lines added by nvm): | |
| if [[ -d "$HOME/.nvm" ]]; then | |
| export NVM_DIR="$HOME/.nvm" | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
| # Configure gemini cli to use vertex api keys https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys | |
| export GOOGLE_GENAI_USE_VERTEXAI=true | |
| export GOOGLE_CLOUD_PROJECT=gregbray-vpc | |
| export GOOGLE_CLOUD_LOCATION=us-central1 | |
| export GOOGLE_API_KEY=AQ.Ab8RN6JM...REDACTED.... | |
| # Settings for Crush to use Vertex AI via GCP ADC https://github.com/charmbracelet/crush | |
| export VERTEXAI_PROJECT=gregbray-vpc | |
| export VERTEXAI_LOCATION=global | |
| # Settings for Claude Code https://docs.anthropic.com/en/docs/claude-code/google-vertex-ai | |
| export CLAUDE_CODE_USE_VERTEX=1 | |
| export CLOUD_ML_REGION=us-east5 | |
| export ANTHROPIC_VERTEX_PROJECT_ID=gregbray-vpc | |
| #export ANTHROPIC_MODEL='claude-opus-4-1@20250805' | |
| #export ANTHROPIC_SMALL_FAST_MODEL='claude-3-5-haiku@20241022' | |
| fi | |
| # open gemini cli in a new project folder and select option 3 for vertex api | |
| cd ~/code/new | |
| gemini |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Crush is a golang based multi-model cli https://github.com/charmbracelet/crush/ | |
| # Install via npm or see git repo for other options (does not require nodejs/npm) | |
| nvm use 22 | |
| npm install -g @charmland/crush | |
| # make sure .bashrc includes these environment variables | |
| export VERTEXAI_PROJECT=gregbray-vpc | |
| export VERTEXAI_LOCATION=global | |
| # Setup ADC (crush does not seem to use API keys, which is good) | |
| # copy the url to a chrome session where you are logged in on argolis | |
| gcloud auth application-default login --no-launch-browser | |
| # Navigate to a project or new folder and start crush. Select Gemini 2.5 Pro or flash as the model | |
| # Easiest to skip the project init stuff and go back to that later | |
| cd ~/code/temp | |
| crush | |
| # after model is selected an also use | |
| crush run "why is the sky blue" | |
| # model selection is stored in ~/.local/share/crush/crush.json | |
| # Add claude-sonnet model from https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/sonnet-4 | |
| # Must enable model for your project using "View model card in Model Garden" first | |
| mkdir -p ~/.config/crush | |
| cat > ~/.config/crush/crush.json << EOF | |
| { | |
| "$schema": "https://charm.land/crush.json", | |
| "lsp": { | |
| "Go": { | |
| "command": "gopls" | |
| } | |
| }, | |
| "providers": { | |
| "vertexai": { | |
| "models": [ | |
| { | |
| "id": "claude-sonnet-4@20250514", | |
| "name": "VertexAI: Sonnet 4", | |
| "cost_per_1m_in": 3, | |
| "cost_per_1m_out": 15, | |
| "cost_per_1m_in_cached": 3.75, | |
| "cost_per_1m_out_cached": 0.3, | |
| "context_window": 200000, | |
| "default_max_tokens": 50000, | |
| "can_reason": true, | |
| "supports_attachments": true | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Claude Code. See full instructions at https://docs.anthropic.com/en/docs/claude-code/google-vertex-ai | |
| # Install cli https://docs.anthropic.com/en/docs/claude-code/overview | |
| nvm use 22 | |
| npm install -g @anthropic-ai/claude-code | |
| # Navigate to your project | |
| cd ~/code/temp | |
| # Make sure the following models are enabled for your project using "view model card in Model Garden" | |
| # https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/sonnet-4 | |
| # https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/haiku-3-5 | |
| # Make sure the following are set in .bashrc | |
| export CLAUDE_CODE_USE_VERTEX=1 | |
| export CLOUD_ML_REGION=us-east5 # not sure why the new global endpoint isn't working | |
| export ANTHROPIC_VERTEX_PROJECT_ID=gregbray-vpc | |
| # Start Claude in a project folder | |
| claude |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment