Integration · Agent

Use a custom model in Gemini CLI

Gemini CLI is Google’s command-line agent and calls the Gemini API. AutoJev answers those calls on a local Gemini-compatible endpoint, translates them to Chat Completions, and routes them to whichever provider and model you choose.

  • Edits ~/.gemini/settings.json and .env together
  • Gemini API → Chat Completions bridge
  • Any provider or route behind it
  • Both files restored on disconnect

Route every request to the right model.

Connect an agent
Codex
Claude Code
Gemini CLI

AutoJev

autojev/quality
openrouter/anthropic/claude-sonnet
deepseek/deepseek-chat
ollama/qwen3:14b

Providers

4

Models

12

Routes

5

Agents

3

Requests today

1,284

Tokens today

18.6M

How the Gemini bridge works

Gemini CLI does not use OpenAI or Anthropic wire formats — it sends generateContent and streamGenerateContent requests in the Gemini API format. AutoJev exposes POST /v1beta/models/{*} for exactly this. Each request is translated into a Chat Completions request and handed to the normal AutoJev pipeline: routing, failover, protocol conversion for the upstream model, logging and cost estimation.

The reply comes back the same way: AutoJev converts the completion into a Gemini response, so Gemini CLI sees a familiar answer whether the model behind it is DeepSeek, an OpenRouter model, a local Ollama model or an AutoJev route.

What AutoJev configures

ItemValue
Config files~/.gemini/settings.json and ~/.gemini/.env (backed up together)
Auth modesecurity.auth.selectedType = "gemini-api-key"
EndpointGOOGLE_GEMINI_BASE_URL = http://127.0.0.1:9527
Modelmodel.name and GEMINI_MODEL = your default model or route
KeyGEMINI_API_KEY = autojev-local-gemini (placeholder; labels requests as gemini)
AdapterGemini-to-Chat bridge

Gemini CLI is connected with your default selection only; it does not get a multi-model catalog.

Set up Gemini CLI with AutoJev

  1. 1

    Install AutoJev

    Download the desktop app and open it. The gateway runs on http://127.0.0.1:9527.

  2. 2

    Add a provider and a model

    Pick a preset (OpenAI, DeepSeek, OpenRouter, Ollama) or any OpenAI-compatible or Anthropic-compatible endpoint, add your key, test it, and add a model.

  3. 3

    Optional: create a route

    Connect a route like autojev/fast instead of a single model when you want AutoJev to pick or fail over between candidates.

  4. 4

    Connect Gemini

    Open Agents. AutoJev detects Gemini CLI if the gemini executable is on your PATH. Choose the default model or route and click Connect.

  5. 5

    Start Gemini CLI

    Start a new session. Requests appear in Logs under the gemini agent.

    bash
    gemini

The config AutoJev writes

AutoJev merges two keys into settings.json and replaces three lines in .env (with autojev/fast as the default). Anything else in either file stays.

~/.gemini/settings.json + ~/.gemini/.env
// ~/.gemini/settings.json — keys AutoJev merges in { "model": { "name": "autojev/fast" }, "security": { "auth": { "selectedType": "gemini-api-key" } } } # ~/.gemini/.env — lines AutoJev sets (other lines are kept) GEMINI_API_KEY=autojev-local-gemini GEMINI_MODEL=autojev/fast GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:9527

Switching models and routes

To use a different model, change the default for Gemini on the Agents page and reconnect, or use “Batch update configurations”. Restart Gemini CLI so it rereads .env.

The simplest setup is to connect a route once and change the route in AutoJev afterwards. Gemini CLI keeps sending the same autojev/<route-id> while AutoJev decides which model answers.

Restoring your Gemini config

settings.json and .env belong to one connection, so they are backed up and restored together. Disconnect, “Stop and restore configurations” or quitting from the tray returns the values AutoJev changed; edits you made afterwards are kept. If a file did not exist before, restoring removes it.

Bridge limits

  • Supports text, inline images and function calls.
  • Streaming buffers the upstream completion and sends it as one SSE event.
  • Token counts reported back to Gemini CLI are estimates.
  • Cached content and non-image inline media are not supported.
  • This is a compatibility adapter, not full Gemini API parity.

Frequently asked questions

Can Gemini CLI use a non-Gemini model?

Yes, through AutoJev. The Gemini bridge translates Gemini API requests to Chat Completions, and AutoJev routes them to any provider you have added, converting again if the upstream speaks Responses or Messages.

Can I use DeepSeek or OpenRouter in Gemini CLI?

Yes. Add the DeepSeek or OpenRouter preset with your key, add a model, and connect Gemini on the Agents page with that model or a route as the default.

Why does streaming arrive in one chunk?

The bridge buffers the upstream completion and emits a single SSE event so function-call arguments stay valid JSON. Output appears when the model finishes.

Does Gemini CLI need a Google API key after connecting?

No. GEMINI_API_KEY is set to the placeholder autojev-local-gemini, which only labels requests. Your provider key lives in AutoJev.

Can I pick from several models inside Gemini CLI?

Gemini is connected with one default model or route. Use a route if you want AutoJev to choose between several models.

Keep exploring

Updated 2026-10-14

Give every agent the right model.

Install AutoJev, add the providers you already pay for, and connect your agents in one click. Everything stays on your machine.

Free & open source · macOS · Windows · Linux