为任何 AI 编码工具掩盖 Coding Plan API - 与 OpenAI 兼容的代理支持工具掩盖、请求转发和多供应商支持
为任何 AI 编码工具掩盖 Coding Plan API - 与 OpenAI 兼容的代理支持工具掩盖、请求转发和多供应商支持
使用教程: Coding‐plan‐mask使用案例 - 如何让 Trae 等 IDE 使用本地/其他大模型
Major AI providers (Zhipu GLM, Alibaba Cloud, MiniMax, DeepSeek, Moonshot, etc.) offer Coding Plan subscriptions at attractive prices, but with severe usage restrictions:
| What You Pay For | What You Actually Get |
|---|---|
| ✅ Fixed monthly fee, unlimited coding | ❌ Only works with specific IDE tools |
| ✅ Access to powerful models | ❌ Cannot use in your favorite tools |
| ✅ Official API Key provided | ❌ Cannot use for automation/backend |
Provider rules, available models, and subscription details can change over time. Treat current provider policy as an external dependency and verify it yourself before use.
Coding Plan Mask is a lightweight local proxy for developers who want to use Coding Plan APIs from their preferred AI coding tools. It masks request origins as officially supported IDE clients, forwards OpenAI/Anthropic-compatible traffic, and can optionally apply local privacy filtering before prompts leave your machine.
┌────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ Your Favorite AI │────▶│ Coding Plan Mask │────▶│ LLM Provider │
│ Tool (Any!) │◀────│ (Tool Masking) │◀────│ (Thinks it's OK) │
└────────────────────┘ └──────────────────────┘ └─────────────────────┘| Feature | Description |
|---|---|
| Tool Masking | Mask as Claude Code, Kimi Code, OpenClaw or custom tool |
| Request Relay | Transparently forward arbitrary upstream API paths |
| Claude CLI Disguise | claudecode mode uses a Claude CLI-style User-Agent and injects x-app: cli when missing |
| Universal Compatibility | Works with ANY OpenAI-compatible client |
| Multi-Provider | Support for 6+ major LLM providers |
| Usage Analytics | Track token consumption in real-time with SQLite storage |
| Readable Logs | Human-friendly token logs in non-debug mode |
| Local Auth | Protect your proxy with custom API key |
| ️ Local Privacy Filter | Off by default; when enabled, applies local S1/S2/S3 policy, redaction, block, full/clean audit, and context selection |
| ⚡ High Performance | Built in Go for maximum efficiency |
| Flexible Configuration | Support TOML config file, environment variables, and custom API URLs |
| Rate Limiting | Built-in rate limiting to prevent abuse |
| Streaming Support | Real-time streaming response forwarding with intelligent detection |
| Two-Phase Storage | Request saved immediately on arrival, updated on response completion |
Download from Releases (Recommended)
Download the binary for your platform from GitHub Releases:
…Build from Source
git clone https://github.com/systemime/coding-plan-mask.git
cd coding-plan-mask
# Build for current platform
make build
# Cross-compile for all platforms
make releasemask-ctlIf you run the binary directly from a folder, the default configuration file will be created beside the executable as config.toml. The loader also recognizes config.eg and config.example.toml in the same directory.
If you install into a protected system path such as /usr/local/bin, prefer either:
make install so the service uses /opt/project/coding-plan-mask/config/config.toml-config /path/to/config.tomlExample when running from the extracted folder:
vim ./config.tomlEdit the configuration file:
…Privacy switch:
enabled = false (default): proxy only; request bodies are not changed by the privacy filter.enabled = true: redact or block locally before forwarding upstream. Configure [auth].local_api_key when this is enabled.Privacy design source: this feature borrows EdgeClaw-Mini's ideas of S1/S2/S3 sensitivity levels, local redact/block policy, full/clean audit tracks, and local context selection. Coding Plan Mask does not depend on or embed EdgeClaw-Mini; it implements a lightweight Go rules baseline inside the local proxy.
# Start the proxy server
mask-ctl
# Or with systemd (after make install)
sudo systemctl start coding-plan-maskConfigure your AI coding tool to use:
{
"base_url": "http://127.0.0.1:8787",
"api_key": "sk-local-secret",
"model": "glm-4-flash"
}If your client hardcodes /v1, that still works. The proxy keeps local management endpoints and transparently forwards any other request path upstream.
In non-debug mode, startup keeps the banner output and proxy activity is shown in a human-friendly text format instead of structured JSON logs.
Privacy filtering is a low-CPU local rules baseline, not a full DLP or ML PII detector. Extend [security.rules] for project-specific secrets.
disguise_tool and use_anthropic do different things:
disguise_tool changes outbound headers/User-Agent so the upstream sees a supported coding client.use_anthropic changes the local API protocol accepted by this proxy.| Local client sends | Local URL/path | Upstream request | Status |
|---|---|---|---|
| OpenAI Chat Completions | http://127.0.0.1:8787/v1/chat/completions |
OpenAI-compatible path/body | Default |
| Anthropic Messages / Claude-style | http://127.0.0.1:8787/v1/messages with use_anthropic=true |
OpenAI-compatible /chat/completions |
Supported |
| OpenAI client → native Anthropic/Claude upstream | OpenAI /v1/chat/completions |
Anthropic /v1/messages |
Not implemented |
When use_anthropic=true, Claude-style clients can call the local proxy with Anthropic Messages format while the upstream remains OpenAI-compatible. Requests, tools, tool results, normal responses, and SSE streams are translated both ways for that path.
Minimal client examples:
// OpenAI-compatible client
{
"base_url": "http://127.0.0.1:8787/v1",
"api_key": "sk-local-secret",
"model": "glm-4-flash"
}# Claude/Anthropic-style client
# config.toml: [api] use_anthropic = true
export ANTHROPIC_BASE_URL=http://127.0.0.1:8787
export ANTHROPIC_API_KEY=sk-local-secret[endpoint]
# Mask as officially supported tools
disguise_tool = "claudecode" # Claude Code-style CLI traffic
# claude_code_user_agent = "claude-cli/2.1.88 (external, cli)"
# disguise_tool = "kimicode" # Kimi Code API subscription auth format
# disguise_tool = "opencode" # Legacy OpenCode disguise id
# opencode_user_agent = "opencode/1.2.27 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.10"
# disguise_tool = "openclaw" # OpenClaw
# openclaw_user_agent = "OpenClaw-Gateway/1.0"
# disguise_tool = "custom" # Use custom User-Agent
# custom_user_agent = "YourCustomTool/1.0"| Tool | Identifier | User-Agent | Description |
|---|---|---|---|
| Claude Code | claudecode |
claude-cli/2.1.88 (external, cli) |
Current default Claude CLI-style UA, configurable via claude_code_user_agent |
| Kimi Code | kimicode |
claude-code/0.1.0 |
Kimi Code API subscription auth format |
| OpenCode | opencode |
opencode/1.2.27 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.10 |
Legacy disguise id with default UA updated from local capture report |
| OpenClaw | openclaw |
OpenClaw-Gateway/1.0 |
Compatibility default, configurable via openclaw_user_agent |
| Custom | custom |
(custom) | Use custom_user_agent config |
Note:
claudecodemode also injectsx-app: cliif the incoming request does not already provide it. Note:opencodemode keeps the legacy disguise id but now defaults to the locally captured OpenCode 1.2.27 UA. Override it withopencode_user_agentif needed. Note:openclawmode keepsOpenClaw-Gateway/1.0as a compatibility default, but this does not imply every current OpenClaw request path uses the same UA.
The proxy reserves a small set of local management endpoints and transparently forwards all other request paths to the upstream provider.
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Service information |
/health |
GET | Health check |
/ready |
GET | Readiness check |
/stats |
GET | Usage statistics (JSON) |
/redact |
POST | Local text redaction |
/privacy/detect |
POST | Local sensitivity detection |
/privacy/policy |
POST | Local allow/redact/review/block decision |
/context/redact / /context/restore |
POST | Redact or restore text/messages context |
/sessions/{id} / /sessions/{id}/messages / /sessions/{id}/context/select |
GET/POST | full/clean audit tracks and local context selection |
/* |
Any | Forward any other path to the upstream API with disguised headers |
# View connection info
mask-ctl info
# View token usage statistics
mask-ctl stats
# Check local configuration
mask-ctl doctor
# View forwarding history
mask-ctl history
# View one request detail
mask-ctl history -id 123
# View help
mask-ctl help
# View usage statistics via API
curl http://127.0.0.1:8787/statsmask-ctl show prints OpenAI-compatible and Anthropic-compatible local URLs.mask-ctl show --json keeps machine-readable connection output for scripts.mask-ctl doctor checks required keys, provider routing, local auth, Anthropic bridge, and privacy mode.mask-ctl history -id prints one full request/response record.You can also configure via environment variables:
| Variable | Description |
|---|---|
PROVIDER |
Provider identifier |
API_KEY |
Coding Plan API Key |
LOCAL_API_KEY |
Local API Key for authentication |
HOST |
Listen host |
PORT |
Listen port |
DEBUG |
Enable debug mode (true/false) |
API_BASE_URL |
Custom API base URL |
API_CODING_URL |
Custom coding endpoint URL |
DISGUISE_TOOL |
Override disguise tool |
CLAUDE_CODE_USER_AGENT |
Override the default UA used by claudecode mode |
OPENCODE_USER_AGENT |
Override the default UA used by opencode mode |
OPENCLAW_USER_AGENT |
Override the compatibility UA used by openclaw mode |
CUSTOM_USER_AGENT |
Override User-Agent directly |
REMOVE_VERSION_PATH |
Remove version prefix (e.g., /v1) from request path when forwarding (true/false) |
MOCK_MODELS |
Enable mock /models endpoint response (true/false) |
MOCK_MODELS_RESP |
Mock /models response content (JSON string) |
USE_ANTHROPIC |
Enable Anthropic format compatibility mode (true/false) |
SECURITY_ENABLED |
Enable local privacy filter (true/false) |
SECURITY_AUDIT_DIR |
Override full/clean audit directory |
SECURITY_HANDLING_S2 / SECURITY_HANDLING_S3 |
Override S2/S3 handling action |
SECURITY_REDACT_EMAIL / SECURITY_REDACT_CHINESE_PHONE / SECURITY_REDACT_CHINESE_ID |
Override default PII redaction toggles |
IMPORTANT: Please read carefully before using this project
This project is provided for educational and research purposes only.
| Risk | Description |
|---|---|
| Terms of Service | May violate your provider's Terms of Service |
| Account Risk | Improper use may result in API key revocation or account suspension |
| No Warranty | Software provided " |
暂无开放 Issues,或尚未同步最近议题。