Gemini CLI
Gemini CLI speaks its own protocol (/v1beta) — and Mixen understands it natively: generateContent, streamGenerateContent (SSE), countTokens and the model list work with any chat model in the catalog, not just Gemini.
Installation
Section titled “Installation”Gemini CLI is an npm package (Node.js 20+ required):
npm install -g @google/gemini-cliAlternatives: brew install gemini-cli (macOS) or npx @google/gemini-cli without installing.
Gemini CLI accepts any Gemini-compatible backend via an environment variable. Use the root https://api.mixen.ai — the /v1beta/… path version is appended by the client itself; adding the segment to the URL would produce a doubled /v1beta/v1beta:
export GOOGLE_GEMINI_BASE_URL="https://api.mixen.ai"export GEMINI_API_KEY="mxn-your-key" # your Mixen key, not a Google onegeminiOn first launch the CLI asks how to authenticate — pick Use Gemini API Key: it reads GEMINI_API_KEY from the environment. In headless mode (gemini -p "…") the menu is not available — set the type explicitly in ~/.gemini/settings.json:
{"security": {"auth": {"selectedType": "gemini-api-key"}}}Also add GEMINI_CLI_TRUST_WORKSPACE=true — without it a non-interactive run refuses to work in an untrusted folder. Pin a default model with GEMINI_MODEL — take the exact id from the catalog (e.g. google/gemini-3.1-pro-preview); pass one ad hoc with gemini --model … or switch mid-session with /model.
Check the wiring before launching the CLI with a single curl:
curl -H "x-goog-api-key: $GEMINI_API_KEY" https://api.mixen.ai/v1beta/modelsGEMINI_TELEMETRY_ENABLED=false disables the CLI’s telemetry.
What works
Section titled “What works”- Blocking and streaming responses —
streamGenerateContent?alt=sse, tokens arrive as deltas. - Function calling — the CLI’s built-in tools (
read_file,edit,shell) go throughfunctionDeclarations; parallel calls are supported. - Reasoning —
thinkingLevelis proxied:low/medium/highcontrol reasoning depth the same wayreasoning_effortdoes in chat. - Context —
countTokensanswers with a cheap estimate without touching the model; the CLI decides on its own when to compact. - Images —
inlineDatareaches the model as vision input (checkcapabilities.visionin the catalog). - Balance and charges — unchanged: balance and history live in the same
GET /v1/balanceandGET /v1/history.
Limitations
Section titled “Limitations”- Only
functionDeclarationsintools; Google Search grounding and other Gemini built-in tools are not proxied — use Sonar models from the catalog for web search. candidateCount > 1is not supported.fileData(the Google File API) does not work — pass files inline or via the Storage API.- Streaming tool calls arrive as one assembled block at the end of the stream, not as argument deltas.
Errors
Section titled “Errors”Errors follow the Gemini standard: {"error": {"code": 401, "message": "...", "status": "UNAUTHENTICATED"}}. Common statuses: UNAUTHENTICATED — the key is missing or revoked; FAILED_PRECONDITION — the account has never been topped up (see keys); RESOURCE_EXHAUSTED — the key hit its request limit.