Contents

CLIProxyAPI Practical Guide: Configure Google Pro Account to Unlock Full Gemini

CLIProxyAPI is a powerful proxy server tool that provides a unified API interface for various AI services (Gemini, Claude, OpenAI, etc.). This article focuses on how to configure a Google Pro Account via CLIProxyAPI, using OAuth authentication to seamlessly invoke Gemini’s advanced models.

1. Preparation

Before starting, ensure you have compiled or downloaded the cli-proxy-api executable file.

2. Prepare Configuration File

First, we need to prepare the config.yaml configuration file.

# Server Configuration
host: ""           # Bind all interfaces; set to "127.0.0.1" to restrict to local access
port: 8317         # Proxy server listening port

# Auth Directory (OAuth tokens will be stored here)
auth-dir: "~/.cli-proxy-api"

# API Keys (Passwords used by clients to access this proxy service)
api-keys:
  - "your-custom-secret-key-1"
  - "your-custom-secret-key-2"

3. Google Account Login Authorization

This is the most critical step. We need to grant CLIProxyAPI permissions to your Google account via OAuth.

3.1 Common Login Commands

Basic Login:

./cli-proxy-api --login

Specify Google Cloud Project ID (Recommended for Pro Users): If you have a specific paid Google Cloud project, it is recommended to explicitly specify it to ensure correct billing and quotas.

./cli-proxy-api --login --project_id your-project-id

Headless Mode (For SSH Remote Servers): If the server has no browser, use this mode. It will generate a URL that you simply open in a local browser to authorize, then paste the verification code back into the terminal.

./cli-proxy-api --login --no-browser

3.2 Authentication Process Analysis

After executing the login command, the system will guide you through the following steps:

  1. Start Local Service: The program starts a temporary HTTP service on port 8085 to receive callbacks.
  2. Browser Authorization:
    • Automatically pops up the Google login page.
    • Requests permissions including cloud-platform and userinfo.
  3. Select Project:
    • The system lists all Cloud projects under your account.
    • Pro User Tip: Be sure to select the Project ID bound to your billing account. Do not select gen-lang-client-* (free/temporary IDs), otherwise you may not enjoy the high rate limits and model access rights of the Pro account.

4. Verification and Launch

4.1 Check Auth Files

After successful authentication, credentials will be saved in your configured auth-dir:

ls -la ~/.cli-proxy-api/
# You should see a file similar to [email protected]

4.2 Start Proxy Service

./cli-proxy-api

At this point, the service will listen on http://localhost:8317 (default) and be ready to receive requests.

5. API Call Example

Once the service is running, you can use clients compatible with OpenAI format to call Gemini models.

Test with Curl:

curl http://localhost:8317/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-custom-secret-key-1" \
  -d '{
    "model": "gemini-2.5-flash",
    "messages": [{"role": "user", "content": "Hello, who are you?"}]
  }'

6. Advanced Usage

Multi-Account Auto-Rotation

CLIProxyAPI supports logging in multiple Google accounts. You only need to run --login multiple times (specifying different projects/accounts). The system will automatically load balance across multiple accounts during runtime, effectively utilizing quotas.

Model Aliases

You can set short aliases for long model names in config.yaml:

oauth-model-alias:
  gemini-cli:
    - name: "gemini-2.5-pro"
    alias: "g2.5p"
    fork: true

FAQ

  1. Does authentication expire? OAuth tokens usually refresh automatically, so frequent re-logins are not needed for long-term operation.
  2. How to distinguish between Free and Pro channels? It mainly depends on the Project ID you select in Login Step 3. Using a Project ID bound to Billing will route through the paid channel.
  3. Are API Keys supported? Yes. Besides OAuth, you can also configure gemini-api-key in config to use API Keys directly, but OAuth is generally more stable and not limited by API Key constraints.