Skip to content
Β 
Β 

Latest commit

Β 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gemini CLI - OpenRouter Edition

npm version License

πŸš€ Enhanced Gemini CLI with OpenRouter Support - Access 200+ AI Models Through One Interface

⚠️ Important Notice: This is a modified version of Google Gemini CLI. Original project copyright belongs to Google LLC under Apache 2.0 License.

🌟 Project Status & Future Development

Current Status: This project currently supports a curated selection of high-performance models through OpenRouter integration. We're actively working to expand model compatibility and enhance features.

Community Driven: Your support helps us grow! ⭐ Star this repository and consider contributing to help us:

  • Add support for more AI models
  • Improve performance and reliability
  • Develop new features and integrations
  • Maintain comprehensive documentation

Get Involved: Have suggestions or want to contribute? Contact us at mythicscribe2014@gmail.com - we'd love to hear from you!

🌐 Language Switch

| πŸ‡ΊπŸ‡Έ English | πŸ‡»πŸ‡³ TiαΊΏng Việt | πŸ‡―πŸ‡΅ ζ—₯本θͺž | πŸ‡©πŸ‡ͺ Deutsch | πŸ‡ΈπŸ‡¦ Ψ§Ω„ΨΉΨ±Ψ¨ΩŠΨ© | πŸ‡¨πŸ‡³ δΈ­ζ–‡ |

🌟 Core Features

  • 🎯 OpenRouter Integration: Access 200+ AI models through OpenRouter's unified API
  • πŸ”„ Model Flexibility: Switch between GPT-4, Claude, Llama, Mistral, and many more
  • 🌍 Global Model Coverage: Supports all major AI models from OpenAI, Anthropic, Meta, Google, and more
  • πŸ”§ Simple Configuration: Single API key for all models
  • πŸ“Š Complete Functionality: Streaming/non-streaming, token counting, function calling all supported
  • πŸš€ Enhanced Performance: Optimized for OpenRouter's high-performance infrastructure

πŸ“¦ Installation

πŸš€ Quick Install (Recommended)

npm install -g @chameleon-nexus-tech/gemini-cli-openrouter

πŸ“‹ Alternative Installation Methods

# Using npm (Node.js package manager)
npm install -g @chameleon-nexus-tech/gemini-cli-openrouter

# Using yarn
yarn global add @chameleon-nexus-tech/gemini-cli-openrouter

# Using pnpm
pnpm add -g @chameleon-nexus-tech/gemini-cli-openrouter

πŸŽ›οΈ OpenRouter Integration

🌐 OpenRouter - Your Gateway to 200+ AI Models

OpenRouter provides access to the world's most advanced AI models through a single, unified API. This enhanced Gemini CLI leverages OpenRouter to give you instant access to:

πŸ”₯ Popular Models Available:

  • anthropic/claude-3.5-sonnet (default) - Anthropic's most capable model
  • openai/gpt-4 - OpenAI's flagship model
  • openai/gpt-4-turbo - Faster GPT-4 variant
  • meta-llama/llama-3.1-8b-instruct - Meta's latest Llama model
  • meta-llama/llama-3.1-70b-instruct - Meta's most powerful Llama
  • mistralai/mistral-7b-instruct - Mistral's efficient model
  • mistralai/mixtral-8x7b-instruct - Mixtral's mixture of experts
  • google/gemini-pro - Google's Gemini model
  • google/gemini-pro-vision - Google's multimodal model
  • cohere/command-r-plus - Cohere's advanced model
  • deepseek/deepseek-coder - Specialized coding model
  • And 190+ more models from leading AI companies!

🎯 Why OpenRouter?

  • Single API Key: Access all models with one credential
  • Best Pricing: Competitive rates across all providers
  • High Availability: 99.9% uptime with global infrastructure
  • Model Comparison: Easy switching between models for testing
  • Enterprise Features: Rate limiting, usage analytics, and more

βš™οΈ Configuration

πŸ”§ Required Environment Variables

You only need to set these 4 environment variables to get started:

# 1. Set AI engine to OpenRouter
export AI_ENGINE="openrouter"

# 2. Set your OpenRouter API key (get from https://openrouter.ai/keys)
export AI_API_KEY="your-openrouter-api-key"

# 3. Choose your preferred model
export AI_MODEL="openai/gpt-4o"

# 4. Set any value to skip Gemini API validation
export GEMINI_API_KEY="any-value-here"

πŸͺŸ Windows PowerShell Configuration

# Set the 4 required environment variables
$env:AI_ENGINE="openrouter"
$env:AI_API_KEY="your-openrouter-api-key"
$env:AI_MODEL="openai/gpt-4o"
$env:GEMINI_API_KEY="any-value-here"

🎯 Quick Setup

That's it! These 4 variables are all you need:

  • AI_ENGINE="openrouter" - Tells the system to use OpenRouter
  • AI_API_KEY="your-key" - Your OpenRouter API key
  • AI_MODEL="model-name" - The AI model you want to use
  • GEMINI_API_KEY="anything" - Set to any value to skip validation

πŸš€ Usage

πŸ’¬ Direct Question Mode

gemini "Hello, please introduce yourself"

πŸ”„ Interactive Mode

gemini

Then select "2. Use Gemini API Key" and press Enter to start chatting.

πŸ§ͺ Model Testing Examples

🌐 Testing with GPT-4o

# Set the 4 required environment variables
export AI_ENGINE="openrouter"
export AI_API_KEY="your-openrouter-api-key"
export AI_MODEL="openai/gpt-4o"
export GEMINI_API_KEY="any-value-here"

# Test command
gemini "Hello, please introduce yourself and tell me which AI model you are."

πŸ—οΈ Technical Architecture

🎯 OpenRouter Integration Architecture

This project features a specialized OpenRouter integration that provides seamless access to 200+ AI models:

OpenRouter Integration
β”œβ”€β”€ OpenrouterContentGenerator    (Primary OpenRouter adapter)
β”œβ”€β”€ ContentGeneratorFactory       (Engine selection and management)
β”œβ”€β”€ Tool Execution System        (Function calling support)
└── Streaming Response Handler    (Real-time response processing)

πŸ”§ Core Features

βœ… OpenRouter Integration: Direct access to 200+ AI models through OpenRouter's unified API
βœ… Model Flexibility: Easy switching between different AI models with a single environment variable
βœ… Automatic Format Conversion: Seamless conversion between Gemini format and OpenRouter API format
βœ… Streaming Response Support: Real-time streaming responses for all supported models
βœ… Function Calling: Full support for tool/function calling across all models
βœ… Intelligent Error Handling: Comprehensive error handling with detailed messages
βœ… Configuration Priority: OpenRouter-specific config > Unified config > Default config

πŸ“ Core File Structure

packages/core/src/core/
β”œβ”€β”€ contentGenerator.ts              # ContentGenerator interface definition
β”œβ”€β”€ contentGeneratorFactory.ts       # Engine factory with OpenRouter priority
β”œβ”€β”€ openrouterContentGenerator.ts    # OpenRouter adapter (primary)
β”œβ”€β”€ coreToolScheduler.ts            # Tool execution and function calling
└── [other adapters]                 # Additional engine support

πŸ”„ OpenRouter API Integration

Request Conversion Flow:

Gemini Request β†’ OpenRouter Adapter β†’ OpenRouter API β†’ 200+ AI Models

Response Conversion Flow:

AI Model Response β†’ OpenRouter API β†’ OpenRouter Adapter β†’ Gemini Response Format

Supported OpenRouter Features:

  • Model Selection: Easy switching between 200+ models
  • Function Calling: Full tool/function calling support
  • Streaming: Real-time response streaming
  • Token Counting: Automatic token usage tracking
  • Error Handling: Comprehensive error management
  • Rate Limiting: Built-in rate limiting and retry logic

πŸ“‹ License Compliance

This project is based on Google Gemini CLI and follows Apache 2.0 License requirements:

Original Project Information

Modification Statement

In accordance with Apache 2.0 License Section 4:

  • βœ… Retained original Apache 2.0 license
  • βœ… Retained original copyright notices
  • βœ… Clearly marked modifications
  • βœ… Included complete license text

πŸ”„ Migration from Original Gemini CLI

If you're migrating from the original Google Gemini CLI:

  1. Uninstall original version: npm uninstall -g @google/gemini-cli
  2. Install this version: npm install -g @chameleon-nexus-tech/gemini-cli
  3. Get OpenRouter API key: Sign up at OpenRouter
  4. Set the 4 required environment variables:
    export AI_ENGINE="openrouter"
    export AI_API_KEY="your-openrouter-api-key"
    export AI_MODEL="openai/gpt-4o"
    export GEMINI_API_KEY="any-value-here"
  5. Use as before: All commands remain the same, now with access to 200+ models!

πŸ§ͺ Testing OpenRouter Integration

πŸš€ Quick Test Script

Create a simple test script to verify your OpenRouter setup:

#!/bin/bash
# test-openrouter.sh

# Set the 4 required environment variables
export AI_ENGINE="openrouter"
export AI_API_KEY="your-openrouter-api-key"
export AI_MODEL="openai/gpt-4o"
export GEMINI_API_KEY="any-value-here"

echo "Testing OpenRouter with GPT-4o..."
gemini "Hello, please introduce yourself and tell me which AI model you are."

πŸ”§ Model Comparison Test

Test different models to compare their responses:

#!/bin/bash
# compare-models.sh

# Set up the base configuration (set once)
export AI_ENGINE="openrouter"
export AI_API_KEY="your-openrouter-api-key"
export GEMINI_API_KEY="any-value-here"

# Test GPT-4o
echo "=== Testing GPT-4o ==="
export AI_MODEL="openai/gpt-4o"
gemini "Write a haiku about artificial intelligence."

πŸ”— Related Links

πŸ› Issue Reporting

If you encounter any issues, please report them on GitHub Issues.

🀝 Contributing

Contributions are welcome! Please ensure:

  1. Follow the original project's code style
  2. Include appropriate tests
  3. Update relevant documentation
  4. Respect the Apache 2.0 license terms

🌟 Project Highlights

  • πŸš€ OpenRouter Integration: Direct access to 200+ AI models through one API
  • 🎯 Model Flexibility: Easy switching between GPT-4, Claude, Llama, and more
  • πŸ”„ Simple Configuration: Single API key for all models
  • 🌍 Global Coverage: Access to models from OpenAI, Anthropic, Meta, Google, and more
  • πŸ“Š Enterprise Grade: Complete error handling and configuration management
  • πŸ”§ Function Calling: Full support for tool/function calling across all models

Disclaimer: This project is not affiliated with Google or OpenRouter. Please comply with the terms of service of the respective platforms when using this software.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages