Unlocking Gemini CLI: Extending Google’s AI Agent for Any LLM

This article introduces the rapidly popular Gemini CLI, compares it with Claude Code, explains its core features, demonstrates coding, multimodal, and MCP use cases, and details the author’s Easy LLM CLI fork that enables custom model integration, flexible configuration, and direct code embedding for developers.

IT Services Circle
IT Services Circle
IT Services Circle
Unlocking Gemini CLI: Extending Google’s AI Agent for Any LLM

Introducing Gemini CLI

Gemini CLI is an open‑source AI Agent command‑line tool developed by Google that has quickly amassed over 60K stars on GitHub, making it one of the hottest projects in its category. The author has forked the original code to create a version that can run any large model, including locally hosted ones, and can be directly imported into other codebases.

Why Gemini CLI Stands Out

Designed to compete with Claude Code, Gemini CLI shares most functional goals but differs by bundling Google’s Gemini 2.5 Pro model by default, offering generous free usage quotas, and being fully open‑source. Its key characteristics are:

Powerful coding abilities with a million‑token context window and customizable user memory, covering the entire code lifecycle.

Support for multimodal files such as images, video, and audio.

An intelligent workflow engine with robust context management, sandboxed execution, and infinite‑loop protection.

Extensibility via the MCP protocol for custom APIs or third‑party tools.

Typical Use Cases

Coding Assistance

Thanks to the built‑in Gemini 2.5 Pro model and its large context window, Gemini CLI can handle complex coding tasks comparable to Claude Code.

帮我查一下最近 1 个月内最热门的 5 篇关于 AI 的论文,然后根据每个论文里的核心内容、原文链接、作者等信息总结成一份详细的分析报告,然后帮我编写一个精美的网页,来展示这些报告。

The tool can automatically search the web using its Google Search integration and generate the requested report and webpage.

Multimodal Processing

Gemini CLI can analyze images, audio, and video. For example, it can process a recent ChatGPT Agent launch video and produce a detailed markdown article.

@gpt.mp4  分析此视频中的音频内容,然后帮我编写一篇详细的中文文章,使用 Markdown 语法,直接保存为本地文件。

MCP Integration

Through the MCP protocol, Gemini CLI can call custom tools such as diagram generators.

帮我详细分析这个项目的技术架构,然后选择几种合适的绘图工具帮我绘制几张技术架构图。

Motivation for Refactoring

The author identified four main pain points with the upstream project:

Account registration requires a Google account and a PROJECT_ID environment variable, which deters many users.

The default Gemini 2.5 Pro model may downgrade to Gemini 2.5 Flash for certain tasks, leading to inconsistent performance.

Potential future pricing could limit free usage; custom model support avoids unexpected costs.

Using a foreign model raises data‑leakage concerns for internal corporate code, which can be mitigated by allowing private model endpoints.

The original CLI only offers interactive commands, making programmatic integration difficult.

Easy LLM CLI (ELC)

The author’s fork, named Easy LLM CLI (ELC), is open‑source (https://github.com/ConardLi/easy-llm-cli) and retains Gemini CLI’s capabilities while adding full custom‑model support.

Key Features of ELC

Custom LLM integration (any provider, any endpoint).

Support for multimodal processing.

Built‑in MCP server connectivity.

Extensible workflow engine.

Testing across several providers demonstrated that most popular models can match or exceed Gemini 2.5 Pro on complex tasks.

Installation

npx easy-llm-cli
npm install -g easy-llm-cli
elc

Configuration via Environment Variables

# Enable custom LLM support
USE_CUSTOM_LLM=true
CUSTOM_LLM_API_KEY="your-api-key"   # Your LLM provider API key
CUSTOM_LLM_ENDPOINT="https://api.your-llm-provider.com/v1"   # API endpoint
CUSTOM_LLM_MODEL_NAME="your-model-name"
# Optional parameters
CUSTOM_LLM_TEMPERATURE=0.7   # Temperature (default 0)
CUSTOM_LLM_MAX_TOKENS=8192   # Max tokens (default 8192)
CUSTOM_LLM_TOP_P=1           # Top‑p (default 1)

ElcAgent API

The core class ElcAgent allows developers to embed AI Agent functionality directly in Node.js applications.

Required Configuration

model (string): Name of the custom LLM.

apiKey (string): API key for the LLM.

endpoint (string): API endpoint URL.

Optional Configuration

authType (AuthType): Authentication type, default AuthType.CUSTOM_LLM_API.

provider (string): LLM provider name.

temperature (number, default 0): Generation temperature.

topP (number, default 1): Top‑p sampling.

maxTokens (number, default 8096): Maximum tokens.

log (boolean, default false): Show detailed logs.

readonly (boolean, default false): Disable file‑write operations.

systemPrompt (string): Custom system prompt.

rootPath (string, default process.pwd()): Working directory.

extension (object): Extension configuration, e.g., MCP servers.

Usage Examples

Example 1: Basic Conversation

import { ElcAgent } from 'easy-llm-cli';

const agent = new ElcAgent({
  model: 'gpt-4',
  apiKey: 'your-openai-api-key',
  endpoint: 'https://api.openai.com/v1',
  log: true,
});

const response = await agent.run('解释一下什么是递归');
console.log('AI 回复:', response);

Example 2: File Operations (non‑readonly)

const agent = new ElcAgent({
  model: 'claude-3-sonnet',
  apiKey: 'your-anthropic-api-key',
  endpoint: 'https://api.anthropic.com/v1',
  readonly: false,
  rootPath: '/path/to/your/project',
});

const response = await agent.run('请帮我创建一个简单的 README.md 文件,包含项目介绍');
console.log(response);

Example 3: Extensions and MCP Server

const agent = new ElcAgent({
  model: 'claude-3-sonnet',
  apiKey: 'your-anthropic-api-key',
  endpoint: 'https://api.anthropic.com/v1',
  log: true,
  extension: {
    mcpServers: {
      chart: {
        command: 'npx',
        args: ['-y', '@antv/mcp-server-chart'],
        trust: false,
      },
    },
    excludeTools: ['run_shell_command'],
  },
});

const response = await agent.run('请帮我生成一个销售数据的柱状图');
console.log(response);

Example 4: Custom System Prompt

const agent = new ElcAgent({
  model: 'your-model',
  apiKey: 'your-api-key',
  endpoint: 'your-endpoint',
  systemPrompt: `你是一个专业的代码审查助手。请遵循以下规则:
1. 总是关注代码质量和最佳实践
2. 提供具体的改进建议
3. 解释为什么某些做法更好
4. 保持友好和建设性的语调`,
  log: true,
});

const response = await agent.run('请审查这个 JavaScript 函数的代码质量');
console.log(response);

Conclusion

Easy LLM CLI was created to satisfy personal needs, is fully open‑source, and is intended solely for learning and non‑commercial use.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

MCPNode.jsAI AgentmultimodalLLM integrationGemini CLI
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.