Gemini CLI Integration
Point Google's official Gemini CLI at Airforce and use any Airforce-hosted model through Google's native Gemini API surface.
Gemini CLI speaks Google's native generateContent REST. Airforce exposes a Gemini-compatible endpoint at https://api.airforce/v1beta/ that translates to OpenAI internally — the CLI needs no patches, just two environment variables.
Install
npm (global)
npm install -g @google/gemini-cliHomebrew (macOS / Linux)
brew install gemini-cliConfigure
Set two environment variables — the Gemini API key slot takes your Airforce key, and the base URL points the bundled @google/genai SDK at Airforce instead of Google.
macOS / Linux
export GEMINI_API_KEY="YOUR_AIRFORCE_API_KEY"
export GOOGLE_GEMINI_BASE_URL="https://api.airforce"
geminiWindows (PowerShell)
$env:GEMINI_API_KEY = "YOUR_AIRFORCE_API_KEY"
$env:GOOGLE_GEMINI_BASE_URL = "https://api.airforce"
geminiPersistent — settings.json
Gemini CLI stores its configuration in ~/.gemini/settings.json. Environment variables still win, so the config below is only needed when you want the settings to travel with your shell profile.
{
"env": {
"GEMINI_API_KEY": "YOUR_AIRFORCE_API_KEY",
"GOOGLE_GEMINI_BASE_URL": "https://api.airforce"
}
}选择模型
Use any id from Airforce's catalog — not just Gemini. Pass it with -m or via the /model slash command in the TUI:
# Agent-capable models (Tools ✓ on the models page)
gemini -m claude-sonnet-4.5 --prompt "Refactor src/parser.ts"
gemini -m gpt-5 --prompt "Explain this stack trace"
gemini -m gemini-3.1-flash-lite --prompt "Summarise CHANGELOG.md"工具调用。 Gemini CLI relies on function-calling for every file edit and shell run. Pick a model marked Tools ✓ on the models page — otherwise the CLI will reply with plain text and never touch your repo.
Troubleshooting
只回复文本,不修改文件
The model you picked doesn't support tool calls through its upstream. Switch to a model marked Tools ✓ on the models page.
401 / "Invalid API key"
Make sure GEMINI_API_KEY is your Airforce key (starts with sk-air-) and GOOGLE_GEMINI_BASE_URL is exactly https://api.airforce (no trailing slash, no /v1).
Gemini CLI 回退到 OAuth 提示
Both env vars must be set in the same shell that launches gemini. Without GEMINI_API_KEY the CLI assumes Google OAuth. Export before running, or put them in ~/.gemini/settings.json.