gcli2api

repository·master·Indexed 26 days ago

https://github.com/su-kaka/gcli2api

A tool that converts GeminiCLI and Antigravity credentials into OpenAI, Gemini, and Claude compatible API interfaces. It provides a management layer for Google OAuth credentials with support for load balancing, automatic rotation, and a web-based control panel. Supports various Gemini models including thinking and search-augmented variants, as well as Antigravity image generation models. Deployable via Docker, Docker Compose, or native installation on Termux, Windows, Linux, and macOS.

Tokens
14.3K
Snippets
35
Records
72
Agent score
89%

What's inside gcli2api

  1. Manage GCLI and Antigravity Authentication Modes

    master

    The service supports dual authentication modes managed through an integrated interface:

    GCLI Authentication Mode

    • Supports standard Google Cloud Gemini API authentication.
    • Supports OAuth2.0 authentication flows.
    • Automatically enables required Google Cloud APIs.

    Antigravity Authentication Mode

    • Dedicated to Google Antigravity API authentication.
    • Uses an independent credential management system.
    • Supports bulk uploading and management.
    • Credentials are completely isolated from GCLI credentials.

    Integrated Management Interface

    Use the "Bulk Upload" (一括アップロード) tab to manage both types:

    • Upper Section (Blue theme): Bulk upload for GCLI credentials.
    • Lower Section (Green theme): Bulk upload for Antigravity credentials.
  2. License and Usage Restrictions (CNC-1.0)

    master

    This project is licensed under the Cooperative Non-Commercial License (CNC-1.0).

    Allowed:

    • Personal learning, research, and education.
    • Non-profit organizations.
    • Integration into open-source projects (must follow the same license).
    • Academic research.

    Prohibited:

    • Any form of commercial use.
    • Use by companies with annual revenue exceeding $1,000,000.
    • Use by venture-capital-backed or publicly traded companies.
    • Providing paid services or products.
    • Commercial competitive use.
  3. Run gcli2api with Docker Compose

    master

    To deploy using Docker Compose, save the following configuration to a docker-compose.yml file and run docker-compose up -d. This configuration supports both shared and separate password modes via environment variables.

    version: '3.8'
    
    services:
      gcli2api:
        image: ghcr.io/su-kaka/gcli2api:latest
        container_name: gcli2api
        restart: unless-stopped
        network_mode: host
        environment:
          # Shared password (Recommended for simple deployment)
          - PASSWORD=pwd
          - PORT=7861
          # OR Separate passwords (Recommended for production)
          # - API_PASSWORD=your_api_password
          # - PANEL_PASSWORD=your_panel_password
        volumes:
          - ./data/creds:/app/creds
        healthcheck:
          test: ["CMD-SHELL", "python -c \"import sys, urllib.request, os; port = os.environ.get('PORT', '7861'); req = urllib.request.Request(f'http://localhost:{port}/v1/models', headers={'Authorization': 'Bearer ' + os.environ.get('PASSWORD', 'pwd')}); sys.exit(0 if urllib.request.urlopen(req, timeout=5).getcode() == 200 else 1)\""]
          interval: 30s
          timeout: 10s
          retries: 3
          start_period: 40s
    docker-compose up -d
  4. Configure MongoDB Cloud Storage

    master
    By default, gcli2api uses a local SQLite database. To use MongoDB for multi-instance deployments or cloud storage, set the MONGODB_URI environment variable. You can also optionally specify a custom database name using MONGODB_DATABASE.
  5. Configure Client Access

    master

    After deploying, access the service at http://127.0.0.1:7861 (default port, configurable via PORT env var) and complete the OAuth authentication process.

    OpenAI Compatible Client Configuration

    • Endpoint URL: http://127.0.0.1:7861/v1
    • API Key: Use the value set in PASSWORD (default: pwd) or API_PASSWORD.

    Gemini Native Client Configuration

    • Endpoint URL: http://127.0.0.1:7861
    • Authentication Options:
      • Authorization: Bearer <your_api_password>
      • x-goog-api-key: <your_api_password>
      • URL parameter: ?key=<your_api_password>
  6. Install gcli2api on Linux

    master

    To install gcli2api on Linux, run the installation script. To restart the service, navigate to the gcli2api directory and execute start.sh.

    # Initial installation
    curl -o install.sh "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/install.sh" && chmod +x install.sh && ./install.sh
    
    # Restart service
    cd gcli2api
    bash start.sh
  7. Install gcli2api on macOS

    master

    To install gcli2api on macOS, run the Darwin installation script. To restart the service, navigate to the gcli2api directory and execute start.sh.

    # Initial installation
    curl -o darwin-install.sh "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/darwin-install.sh" && chmod +x darwin-install.sh && ./darwin-install.sh
    
    # Restart service
    cd gcli2api
    bash start.sh
  8. Run gcli2api with Docker

    master

    You can run gcli2api using Docker. You can choose between using a single shared password or separate passwords for the API and the management panel.

    Using a shared password: Set the PASSWORD environment variable.

    Using separate passwords: Set API_PASSWORD for chat endpoints and PANEL_PASSWORD for the control panel.

    # Using shared password (Linux/Generic)
    docker run -d --name gcli2api --network host -e PASSWORD=pwd -e PORT=7861 -v $(pwd)/data/creds:/app/creds ghcr.io/su-kaka/gcli2api:latest
    
    # Using separate passwords (Linux/Generic)
    docker run -d --name gcli2api --network host -e API_PASSWORD=api_pwd -e PANEL_PASSWORD=panel_pwd -e PORT=7861 -v $(pwd)/data/creds:/app/creds ghcr.io/su-kaka/gcli2api:latest
    
    # Docker Mac (Port mapping required)
    docker run -d \
      --name gcli2api \
      -p 7861:7861 \
      -p 8080:8080 \
      -e PASSWORD=pwd \
      -e PORT=7861 \
      -v "$(pwd)/data/creds":/app/creds \
      ghcr.io/su-kaka/gcli2api:latest
  9. Initial Setup and Authentication Flow

    master

    To set up the service, access the web interface at http://127.0.0.1:7861 (the port can be changed via the PORT environment variable). Complete the OAuth authentication flow using the default password pwd (this can be changed via the API_PASSWORD or PASSWORD environment variables).

    There are two modes for credential acquisition:

    • GCLI mode: For obtaining Google Cloud Gemini API credentials.
    • Antigravity mode: For obtaining Google Antigravity API credentials.
  10. Install gcli2api on various environments

    master

    Follow the specific commands for your operating system to install and run the service.

    Termux

    Initial Install:

    curl -o termux-install.sh "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/termux-install.sh" && chmod +x termux-install.sh && ./termux-install.sh

    Restart Service:

    cd gcli2api
    bash termux-start.sh

    Windows

    Initial Install:

    iex (iwr "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/install.ps1" -UseBasicParsing).Content

    Restart Service: Double-click start.bat.

    Linux

    Initial Install:

    curl -o install.sh "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/install.sh" && chmod +x install.sh && ./install.sh

    Restart Service:

    cd gcli2api
    bash start.sh

    macOS

    Initial Install:

    curl -o darwin-install.sh "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/darwin-install.sh" && chmod +x darwin-install.sh && ./darwin-install.sh

    Restart Service:

    cd gcli2api
    bash start.sh
  11. Deploy gcli2api using Docker

    master

    You can deploy using standard Docker commands or Docker Compose. Use PASSWORD for a single universal password, or API_PASSWORD and PANEL_PASSWORD to separate API access from the management panel.

    Docker Run (Linux/Host Network)

    # Using universal password
    docker run -d --name gcli2api --network host -e PASSWORD=pwd -e PORT=7861 -v $(pwd)/data/creds:/app/creds ghcr.io/su-kaka/gcli2api:latest
    
    # Using separate passwords
    docker run -d --name gcli2api --network host -e API_PASSWORD=api_pwd -e PANEL_PASSWORD=panel_pwd -e PORT=7861 -v $(pwd)/data/creds:/app/creds ghcr.io/su-kaka/gcli2api:latest

    Docker Run (macOS/Port Mapping)

    # Using universal password
    docker run -d \
      --name gcli2api \
      -p 7861:7861 \
      -p 8080:8080 \
      -e PASSWORD=pwd \
      -e PORT=7861 \
      -v "$(pwd)/data/creds":/app/creds \
      ghcr.io/su-kaka/gcli2api:latest
    
    # Using separate passwords
    docker run -d \
    --name gcli2api \
    -p 7861:7861 \
    -p 8080:8080 \
    -e API_PASSWORD=api_pwd \
    -e PANEL_PASSWORD=panel_pwd \
    -e PORT=7861 \
    -v $(pwd)/data/creds:/app/creds \
    ghcr.io/su-kaka/gcli2api:latest

    Docker Compose

    1. Save the following as docker-compose.yml:
    version: '3.8'
    
    services:
      gcli2api:
        image: ghcr.io/su-kaka/gcli2api:latest
        container_name: gcli2api
        restart: unless-stopped
        network_mode: host
        environment:
          # Using universal password (recommended for simple deployment)
          - PASSWORD=pwd
          - PORT=7861
          # Or use separate passwords (recommended for production)
          # - API_PASSWORD=your_api_password
          # - PANEL_PASSWORD=your_panel_password
        volumes:
          - ./data/creds:/app/creds
        healthcheck:
          test: ["CMD-SHELL", "python -c \"import sys, urllib.request, os; port = os.environ.get('PORT', '7861'); req = urllib.request.Request(f'http://localhost:{port}/v1/models', headers={'Authorization': 'Bearer ' + os.environ.get('PASSWORD', 'pwd')}); sys.exit(0 if urllib.request.urlopen(req, timeout=5).getcode() == 200 else 1)\"]"
          interval: 30s
          timeout: 10s
          retries: 3
          start_period: 40s
    1. Run docker-compose up -d.
    docker-compose up -d
  12. Configure API clients for gcli2api

    master

    After deploying, access the web management console at http://127.0.0.1:7861 (default port) to complete the OAuth authentication flow. Once configured, use the following settings for your clients:

    OpenAI Compatible Client

    • Endpoint Address: http://127.0.0.1:7861/v1
    • API Key: Use the value set in PASSWORD or API_PASSWORD (default is pwd).

    Gemini Native Client

    • Endpoint Address: http://127.0.0.1:7861
    • Authentication Methods:
      • Authorization: Bearer <your_password>
      • x-goog-api-key: <your_password>
      • URL parameter: ?key=<your_password>