cmm — Claude Model Mapping

Transparent OS-level model interception for Claude Code. Redirect any model to Google Gemini — zero config changes.

$ sudo cmm claude-haiku-4-5 gemini-2.5-flash

How It Works

Claude Code (unmodified, no env vars, no patches) | | HTTPS -> api.anthropic.com:443 | v +--------------------------------------+ | cmm — Local HTTPS Server (:443) | | Trusted self-signed certificate | | | | model = haiku? | | YES -> Gemini API (target model) | | NO -> Real api.anthropic.com | +--------------------------------------+

Features

🎧

Zero Config

No env vars, no patches, no Claude Code modifications. Just run cmm and open Claude Code normally.

🔀

Full Translation

Messages, tool use, streaming, thinking blocks, images — all translated between Anthropic and Gemini formats in real-time.

Streaming SSE

Real-time streaming translation. Gemini SSE chunks are converted to Anthropic SSE events on the fly.

🔒

Secure

Certificates scoped to api.anthropic.com only. Private keys chmod 600. Clean shutdown always restores /etc/hosts.

🔧

Tool Use

Full bidirectional tool use translation — tool_use/tool_result mapped to functionCall/functionResponse.

🛠

Uses Gemini CLI Auth

No separate API key needed. Uses your existing Gemini CLI OAuth credentials automatically.

Quick Start

1

Prerequisites

Install and log in to both CLIs:

# Claude Code (installed and logged in)
claude --version

# Gemini CLI (for OAuth credentials)
npm install -g @google/gemini-cli
gemini  # Follow the OAuth login flow
2

Install cmm

npm install -g claude-model-mapping
3

One-time setup

Generate certificates and trust them in macOS Keychain:

cmm setup

Open a new terminal after setup.

4

Start intercepting

# Terminal 1: Start cmm
sudo cmm claude-haiku-4-5 gemini-2.5-flash

# Terminal 2: Use Claude Code normally
claude

Routing

Model names use prefix matching — claude-haiku-4-5 catches claude-haiku-4-5-20251001 too.

Request Model Behavior Destination
claude-haiku-4-5* INTERCEPTED Gemini API (target model)
Everything else PASSTHROUGH Real api.anthropic.com
Non-messages endpoints PASSTHROUGH Real api.anthropic.com
[18:01:32] claude-opus-4-6 -> PASSTHROUGH
[18:01:45] claude-haiku-4-5-20251001 -> INTERCEPTED -> gemini-2.5-flash
[18:01:48] claude-sonnet-4-20250514 -> PASSTHROUGH
[18:02:01] GET /v1/models -> PASSTHROUGH