Gemini Provider
Access Google Gemini models via OAuth authentication with automatic token management and interactive model configuration.Quick Start
Authentication
Initial Setup
1
First Run
Run
ccs gemini "your prompt" - browser opens automatically2
Google OAuth
Sign in with your Google account
3
Token Cached
OAuth token saved to
~/.ccs/cliproxy/auth/gemini-{email}.json4
Auto Refresh
Token refresh is handled automatically by CLIProxy
OAuth Flow Specifics
Authorization Code Flow:- Callback server spawns on provider-specific port
- Browser opens for Google OAuth consent
- Token received via HTTP callback
- Runtime-managed refresh prevents mid-request failures
- refresh ownership is delegated upstream to CLIProxy
- CCS verifies that local auth material still exists
- prevents common mid-session auth failures without requiring manual refresh in normal flows
- prompts for re-auth if upstream refresh can no longer recover the session
Headless Authentication
For servers without browser access:Multi-Account Support
Manage multiple Google accounts seamlessly:- Add Account
- List Accounts
- Switch Account
~/.ccs/cliproxy/accounts.json
Real-Time Quota Display
CCS displays real-time quota information for Gemini accounts via Dashboard and CLI.Dashboard Display
Location: Dashboard → OAuth Providers → Gemini Displays:- Requests per minute (RPM) usage
- Tokens per minute (TPM) usage
- Requests per day (RPD) usage
- Limit reset times
- Quota data cached for 2 minutes to reduce API load
- Automatic re-authentication if token expired
- Dashboard shows cached timestamp
CLI Quota Check
- Displays all authenticated Gemini accounts
- Shows cached timestamp (2-minute cache)
- Proactive token refresh (5 minutes before expiry)
Cache Location: In-memory (not persisted to disk)
Tool Name Sanitization
Gemini enforces a 64-character limit on tool names. CCS automatically handles this via ToolSanitizationProxy.The Problem
Claude MCP tools can have names exceeding 64 characters:How CCS Fixes It
ToolSanitizationProxy intercepts requests and:- Detects tool names exceeding 64 characters
- Creates short hashes using
<prefix>_<6-char-md5>format (e.g.,mcp__long-server__toolName→mcp___a1b2c3) - Maintains bidirectional mapping
- Restores original names in responses
Architecture
- Spawned automatically when using Gemini provider
- Runs on random port (127.0.0.1)
- Shuts down with Claude session
Sanitization Process
Request Flow:Debug Mode
Enable verbose logging to see sanitization activity:~/.ccs/logs/tool-sanitization-proxy.log
When Sanitization Happens
Automatically enabled for:- All CLIProxy providers (gemini, codex, antigravity)
- Any provider configured via
config.cliproxy
- ToolSanitizationProxy runs for all CLIProxy-based providers to ensure compatibility across different model APIs
Configuration
Sanitization is automatic and requires no configuration. To disable warnings:Performance Impact
Minimal overhead:- Hash generation: under 1ms per tool
- Request/response transformation: under 5ms
- In-memory mapping (no disk I/O)
timeoutMs)
Model Configuration
Interactive Model Picker
Select Gemini model interactively with--config flag:
Available Models
Model Settings Storage
Settings saved to~/.ccs/gemini.settings.json:
Configuration
Config Keys
Configure via~/.ccs/config.yaml:
Environment Variables
These are set automatically by CCS. Manual override rarely needed.
Commands Reference
Basic Usage
Authentication Commands
Account Management
Configuration
Troubleshooting
Token Refresh Failures
Symptom:UND_ERR_SOCKET errors during execution
Cause: Token expired mid-request
Solution: Proactive refresh handles this automatically. If issue persists:
Model Not Working
Symptom: API errors, tool call failures Cause: Model incompatible with Claude Code Solution: Change model via--config:
Multiple Accounts Confusion
Symptom: Wrong account being used Solution: Check default account:Browser Doesn’t Open
Symptom: OAuth flow stuck waiting for browser Solution: Use headless mode:Storage Locations
Cost Information
Quota Management: Automatic rotation if rate limited (config:
quota-exceeded.switch-project: true)
Advanced Features
Token Structure
OAuth token file format (gemini-{email}.json):
Proactive Refresh Logic
- Before execution: Check
expiry_date - If < 5 minutes until expiry: Trigger refresh
- If refresh succeeds: Update token file
- If refresh fails: Prompt re-auth
- Execute Claude CLI with valid token
Next Steps
Multi-Account Setup
Configure multiple Google accounts
Model Selection
Choose optimal Gemini model
Remote Proxy
Connect to external CLIProxy server
WebSearch Integration
Enable Gemini-powered web search
