Skip to content

asathinkeroops/cmm

Repository files navigation

code-models-manager (cmm)

CMM is a multi-model API gateway: By intercepting the BaseURL configuration of code agents, it centralizes all requests and routes them to upstream model providers, supporting ClaudeCode, OpenCode, Codex and other popular code agent tools.

Architecture

CMM Architecture

Screenshots

Model Manager ClaudeCode Config

Key Features

  • Multi-model API Gateway: Configure multiple models (each with different API Key, BaseURL, model name), call with a unified ID, and the gateway automatically routes to the correct upstream
  • Code Agent Integration: Intercept ClaudeCode/OpenCode/Codex's BaseURL configuration to centralize their requests through the CMM gateway
  • Dual Protocol Support: Compatible with OpenAI (/v1/chat/completions), Anthropic (/v1/messages) and Codex (/v1/responses) protocols
  • Web Admin Interface: Visual configuration for models and ClaudeCode settings management
  • Startup Service: Support for macOS/Linux/Windows system service installation

Quick Start

# Install
npm install -g @asathinkeroops/cmm

# Install global auto-start service
cmm install

# Open configuration page to configure models
cmm config

Usage

# Show help
cmm --help

# Install startup service
cmm install

# Uninstall startup service
cmm uninstall

# View current configuration
cmm config

# View service status
cmm status

CMM Status

Build from source

go install github.com/asathinkeroops/cmm@latest

API Endpoints

Model Management

Method Path Description
GET /cmm/models Get model list
GET /cmm/models/:id Get specific model
POST /cmm/models Create model
PUT /cmm/models/:id Update model
DELETE /cmm/models/:id Delete model
DELETE /cmm/models Clear all models

ClaudeCode Configuration

Method Path Description
GET /cmm/claudecode Get full ClaudeCode settings
PUT /cmm/claudecode Update full ClaudeCode settings
GET /cmm/claudecode/env Get ClaudeCode env variables
PUT /cmm/claudecode/env Update ClaudeCode env variables

API Proxy

Method Path Description
POST /v1/chat/completions OpenAI protocol proxy
POST /v1/messages Anthropic protocol proxy
POST /v1/messages/count_tokens Anthropic count_tokens proxy
POST /v1/responses Codex protocol proxy

Admin Interface

Method Path Description
GET /admin Web admin interface
GET /admin/* SPA routing support

Development

Requirements

  • Go 1.26+
  • Node.js 18+ (for frontend development)

Common Commands

# Run the program
go run .

# Start server
go run . serve

# Build
go build -o cmm .

# Add new subcommand
cobra-cli add <command-name>

# Frontend development
cd frontend
pnpm install
pnpm dev

# Frontend build
pnpm build

Project Structure

.
├── cmd/
│   ├── root.go           # Root command definition
│   ├── serve.go          # serve subcommand (starts HTTP server)
│   ├── install.go        # install subcommand (install startup service)
│   └── uninstall.go      # uninstall subcommand (uninstall startup service)
├── internal/
│   ├── config/
│   │   ├── config.go     # Model config manager (singleton pattern)
│   │   └── claudecode.go # ClaudeCode config manager
│   ├── handler/
│   │   ├── model.go      # Model CRUD endpoints
│   │   ├── claudecode.go # ClaudeCode config endpoints
│   │   └── admin.go      # Admin page handler
│   ├── model/
│   │   ├── model.go      # Model data structure
│   │   └── claudecode.go # ClaudeCode Settings structure
│   ├── proxy/
│   │   └── proxy.go      # OpenAI/Anthropic protocol proxy
│   ├── service/
│   │   ├── service.go            # Service interface definition
│   │   ├── service_darwin.go     # macOS implementation
│   │   ├── service_linux.go      # Linux implementation
│   │   ├── service_windows.go    # Windows implementation
│   │   └── service_other.go      # Other platform implementation
│   ├── serverinfo/
│   │   └── serverinfo.go # Server runtime info management
│   └── static/
│   │   └── embed.go      # Static file embedding
├── frontend/              # React + TypeScript frontend
│   ├── src/
│   │   ├── api/          # API calls
│   │   ├── components/   # UI components (shadcn/ui)
│   │   ├── layouts/      # Layout components
│   │   ├── pages/        # Page components
│   │   │   ├── ClaudeCode/  # ClaudeCode config page
│   │   │   ├── Models/      # Models management page
│   │   │   ├── OpenCode/    # OpenCode config page (reserved)
│   │   │   └── Codex/       # Codex config page (reserved)
│   │   ├── router/       # Router configuration
│   │   ├── store/        # Zustand state management
│   │   └── types/        # TypeScript type definitions
│   └── package.json
├── docs/                  # Documentation directory
├── main.go               # Main entry point
├── go.mod                # Go module file
├── CLAUDE.md             # Claude Code project instructions
└── README.md             # Project README file

Configuration Files

  • Model config: ~/.cmm/config.json
  • ClaudeCode config: ~/.claude/settings.json

Build

# Local build
go build -o cmm .

# Cross-platform build
GOOS=linux GOARCH=amd64 go build -o cmm-linux .
GOOS=darwin GOARCH=amd64 go build -o cmm-darwin .
GOOS=windows GOARCH=amd64 go build -o cmm.exe .

Dependencies

License

Apache 2.0

About

CMM is a multi-model API gateway: By intercepting the BaseURL configuration of code agents, it centralizes all requests and routes them to upstream model providers, supporting ClaudeCode, OpenCode, Codex and other popular code agent tools.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors