Coding Tools
Gemini CLI
Configure Google Gemini CLI to use TokenLab API
Overview
Gemini CLI 0.60.0 documents GOOGLE_GEMINI_BASE_URL for API-key authentication. Use TokenLab’s Gemini-native endpoint with a current model that supports gemini_generate_content. See the official configuration reference and authentication guide. This setup does not route a Google subscription through TokenLab.
Installation
npm install -g @google/gemini-cli@0.60.0
gemini --versionConfiguration
Use the Quickstart terminal instructions for macOS, Linux, WSL, or Windows PowerShell to set TOKENLAB_API_KEY without putting the key in command history. Launch Gemini CLI from that terminal. For persistent use, use your local secret manager; do not append a plaintext key to your shell profile.
Keep your current Google login and configuration. For a separate TokenLab launch, choose an unused configuration root such as ~/.gemini-tokenlab ($HOME on PowerShell) and create its .gemini directory. Copy your existing .gemini/settings.json and any policy files needed by your setup into the corresponding locations, preserving permissions, sandbox and unrelated settings. In that copy only, merge the following authentication field; create a settings file if none exists. Do not copy OAuth caches or clear your original credentials. Follow managed authentication policy instead of overriding it.
{
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}Usage
The launch below uses ~/.gemini-tokenlab/.gemini/settings.json. Adjust the path if you chose another root. Approve the working directory through Gemini’s normal trust prompt; keep existing tool-approval policies. The model is selected explicitly for this session.
GEMINI_CLI_HOME="$HOME/.gemini-tokenlab" GEMINI_API_KEY="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" GOOGLE_GEMINI_BASE_URL=https://api.tokenlab.sh gemini --model gemini-3.5-flashThese variables apply only to this launch; your saved account, default model and permission settings stay in place. Launch normally without the variables to use your previous setup. Do not persist them in your shell profile.
Verify
Saving settings or listing models does not verify a key or a completed request. A prompt uses TokenLab balance. Check the reply and its matching request record before trying tools; auxiliary requests may also be billed.
Reply only with TOKENLAB_CONNECTION_OK. Do not use tools or modify files.