Skip to content
RU

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.

Gemini CLI is an npm package (Node.js 20+ required):

npm install -g @google/gemini-cli

Alternatives: 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 one
gemini

On 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/models

GEMINI_TELEMETRY_ENABLED=false disables the CLI’s telemetry.

  • Blocking and streaming responsesstreamGenerateContent?alt=sse, tokens arrive as deltas.
  • Function calling — the CLI’s built-in tools (read_file, edit, shell) go through functionDeclarations; parallel calls are supported.
  • ReasoningthinkingLevel is proxied: low/medium/high control reasoning depth the same way reasoning_effort does in chat.
  • ContextcountTokens answers with a cheap estimate without touching the model; the CLI decides on its own when to compact.
  • ImagesinlineData reaches the model as vision input (check capabilities.vision in the catalog).
  • Balance and charges — unchanged: balance and history live in the same GET /v1/balance and GET /v1/history.
  • Only functionDeclarations in tools; Google Search grounding and other Gemini built-in tools are not proxied — use Sonar models from the catalog for web search.
  • candidateCount > 1 is 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 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.