cmm — Claude Model Mapping

Transparent OS-level model interception for Claude Code. Redirect any model via CLIProxyAPI — 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 -> CLIProxyAPI (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.

🔀

Direct Passthrough

Anthropic-format requests forwarded directly to CLIProxyAPI. No translation layer — maximum compatibility.

Streaming SSE

Real-time streaming with backpressure support. 429 rate-limit auto-retry with intelligent delay parsing.

🔒

Secure

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

🔧

Smart Routing

Prefix-based model matching. Intercepted models go to CLIProxyAPI, everything else passes through untouched.

🛠

Easy Config

Built-in CLI for proxy settings. cmm config set PROXY_API_KEY sk-... — no file editing needed.

Service Mode

Run as a macOS launchd daemon. Auto-starts on boot, auto-restarts on crash. No terminal window needed.

Quick Start

1

Prerequisites

Install Claude Code and have CLIProxyAPI running:

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

# CLIProxyAPI running on localhost:8317
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

# Or set defaults and just run: sudo cmm
cmm config set DEFAULT_SOURCE_MODEL claude-haiku-4-5
cmm config set DEFAULT_TARGET_MODEL gemini-2.5-flash
sudo cmm

# Terminal 2: Use Claude Code normally
claude

Service Mode

Run cmm as a macOS launchd daemon — no terminal window required.

1

Install and start

Creates a LaunchDaemon that auto-starts on boot and auto-restarts on crash.

sudo cmm service install claude-haiku-4-5 gemini-2.5-flash
2

Manage

# Check status
sudo cmm service status

# Stop / start / restart
sudo cmm service stop
sudo cmm service start
sudo cmm service restart
3

Remove

Stops the service and removes the LaunchDaemon plist.

sudo cmm service uninstall

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 CLIProxyAPI (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