Install Gemini CLI
Install it globally with npm (Node.js required):Configure LaoZhang API
1
Set the environment variables
Add these two lines to your shell profile (Use the bare host, without
~/.zshrc for zsh, ~/.bashrc for bash), then open a new terminal:/v1 or /v1beta; Gemini CLI builds the path itself.2
Choose Gemini API key sign-in
The first time you run Don’t choose Login with Google, which connects to your Google account and bypasses LaoZhang API.
gemini, it asks how to sign in. Choose Use Gemini API Key. You can also set it in ~/.gemini/settings.json:3
Pick a model and test
In a project directory, run:For a quick non-interactive check:Non-interactive mode only runs in a trusted directory. The first time you use a new directory, trust it from interactive mode.
Choose a model
Pass
-m every time you start, so Gemini CLI doesn’t fall back to a default model ID that LaoZhang API doesn’t offer. Prices are in the model catalog; routing details are in Gemini protocol.
FAQ
I get “API key not valid” or requests go to Google
Make sureGOOGLE_GEMINI_BASE_URL is set in the current terminal (echo $GOOGLE_GEMINI_BASE_URL) and that the sign-in method is Gemini API key. A different GEMINI_API_KEY in your project directory or ~/.gemini/.env may also be read, so check those too.
The model doesn’t exist
Model IDs must match the model catalog exactly. SendGET https://api.laozhang.ai/v1/models with the same key to confirm the ID is listed.