Skip to main content
To run Gemini CLI on LaoZhang API, set GOOGLE_GEMINI_BASE_URL to https://api.laozhang.ai, put your LaoZhang API key in the key variable, and sign in with Use Gemini API Key.

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 (~/.zshrc for zsh, ~/.bashrc for bash), then open a new terminal:
Use the bare host, without /v1 or /v1beta; Gemini CLI builds the path itself.
2

Choose Gemini API key sign-in

The first time you run gemini, it asks how to sign in. Choose Use Gemini API Key. You can also set it in ~/.gemini/settings.json:
Don’t choose Login with Google, which connects to your Google account and bypasses LaoZhang API.
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 sure GOOGLE_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. Send GET https://api.laozhang.ai/v1/models with the same key to confirm the ID is listed.

Can Gemini CLI generate images?

Gemini CLI is built for chat and coding. To generate images, call the Nano Banana API directly; see Nano Banana API.