Skip to main content

Gemini CLI

Use Gemini CLI with NanoGPT to access Gemini, GPT, Claude, and 400+ models through a single API key.
Get started with NanoGPT for pay-as-you-go pricing with no monthly fees. Add credits and start immediately.
Gemini CLI is Google’s official command-line interface for Gemini. The official CLI only targets Google endpoints, so use the community fork that adds OpenRouter and OpenAI-compatible support to point it at NanoGPT.

Step 1: Install the OpenRouter Fork

Prerequisites: Node.js 18 or newer
git clone https://github.com/heartyguy/gemini-cli
cd gemini-cli
git checkout feature/openrouter-support
npm install
This fork is community maintained. If the branch name changes or is missing, check the repository README for the latest OpenRouter-compatible branch.

Step 2: Configure NanoGPT

1

Get API Key

  • Go to NanoGPT API
  • Create an account or log in
  • Copy your API key (starts with sk-nano-)
2

Set Environment Variables

Set the base URL and API key in the same shell where you will run the CLI:
export OPENROUTER_BASE_URL="https://nano-gpt.com/api/v1"
export OPENROUTER_API_KEY="sk-nano-YOUR-API-KEY"
For persistent configuration, add the exports to your shell profile:
echo 'export OPENROUTER_BASE_URL="https://nano-gpt.com/api/v1"' >> ~/.zshrc
echo 'export OPENROUTER_API_KEY="sk-nano-YOUR-API-KEY"' >> ~/.zshrc
source ~/.zshrc

Step 3: Start Gemini CLI

From the gemini-cli folder, launch the CLI:
npm start
On first launch, the CLI may prompt you to select a theme or complete authentication required by the fork.

Models

Once connected, you can use any model listed on the NanoGPT pricing page, including:
  • google/gemini-3-pro-preview
  • google/gemini-3-flash-preview
  • openai/gpt-5.2
  • anthropic/claude-opus-4.5

Optional: Verify Your Connection

curl -X POST "https://nano-gpt.com/api/v1/chat/completions" \
  -H "Authorization: Bearer sk-nano-YOUR-API-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3-flash-preview",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Troubleshooting

IssueSolution
401 UnauthorizedCheck your API key and ensure your account has credits
Connection refusedVerify OPENROUTER_BASE_URL is set to https://nano-gpt.com/api/v1
Model not foundConfirm the model name at nano-gpt.com/pricing
CLI not recognizing variablesRestart your terminal or set the variables in the same session