面向 cc switch + Codex 的 Xiaomi MiMo 本地路由桥接器。
不只是反向代理——主动协议适配,让你在 Codex 里无缝使用 MiMo。
A local routing bridge that brings Xiaomi MiMo to cc switch + Codex.
Not just a reverse proxy — an active protocol adapter for seamless MiMo integration.
CCMimoLink 的核心价值在于主动协议适配,而不只是请求转发。
CCMimoLink's core value lies in active protocol adaptation, not just request forwarding.
把 OpenAI 风格的 Responses 请求翻译成 MiMo chat-completions 格式,注入 instructions 为 system message。
Translates OpenAI-style Responses into MiMo chat-completions format, injecting instructions as system messages.
保留标准 function tool,规范化 tool_choice,过滤不兼容的 built-in tool 避免上游崩溃。
Preserves standard function tools, normalizes tool_choice, and filters incompatible built-in tools.
通过有界内存保存 response-chain 状态,支持 previous_response_id,回放函数调用上下文。
Bounded in-memory state for response chains, supports previous_response_id and function-call replay.
保留真实增量流式路径,读取 MiMo 上游流时发出 Responses 风格事件。
Preserves true incremental streaming, emitting Responses-style events from the MiMo upstream stream.
请求中带图片时,自动回落到 mimo-v2.5 保证兼容性。
Image-containing requests automatically fall back to mimo-v2.5 for compatibility.
纯文本请求可在 mimo-v2.5 与 mimo-v2.5-pro 之间通过环境变量或启动参数切换。
Switch text traffic between mimo-v2.5 and mimo-v2.5-pro via env vars or startup flags.
回写 Codex 配置前自动备份,限流与 429 退避处理,XML 兜底解析。
Auto-backup before config rewrite, throttling with 429 backoff, XML fallback parsing.
对 compact 控制面请求提供本地处理,不把错误甩给上游。
Handles compact control-plane requests locally instead of letting them fail upstream.
在 cc switch 中添加 Xiaomi MiMo provider 并填入 API Key。
Add a Xiaomi MiMo provider in cc switch and enter your API key.
go build -o ccmimolink .
只做配置同步,不启动代理服务:
Rewrite routes and refresh config without starting the proxy:
./ccmimolink --sync-only
./ccmimolink
http://127.0.0.1:9876/v1
纯文本请求默认使用 mimo-v2.5,可通过以下方式切换到 mimo-v2.5-pro:
Text requests default to mimo-v2.5. Switch to mimo-v2.5-pro:
# 环境变量方式Environment variable
MIMO_MODEL="mimo-v2.5-pro" ./ccmimolink
# 启动参数方式Startup flag
./ccmimolink --v2.5-pro
所有运行时配置通过环境变量提供。
All runtime settings are provided via environment variables.
| 变量 | Variable | 默认值 | Default | 说明 | Description |
|---|---|---|---|---|---|
MIMO_API_KEY |
空empty | MiMo 上游备用 API KeyFallback MiMo upstream API key | |||
MIMO_BASE_URL |
https://token-plan-cn.xiaomimimo.com/v1 |
MiMo 上游地址MiMo upstream base URL | |||
MIMO_MODEL |
mimo-v2.5 |
默认文本模型Default text model | |||
MIMO_PROXY_PORT |
9876 |
本地监听端口Local listen port | |||
MIMO_PROXY_MAX_CONCURRENT |
1 |
最大并发上游请求数Maximum concurrent upstream requests | |||
MIMO_PROXY_MIN_INTERVAL_MS |
1500 |
上游请求最小间隔(毫秒)Minimum delay between upstream requests (ms) | |||
MIMO_PROXY_429_BACKOFF_MS |
30000 |
收到 429 后的退避时间(毫秒)Backoff after upstream 429 (ms) | |||
MIMO_PROXY_LOG |
ccmimolink.log |
日志文件路径Log file path | |||
MIMO_PROXY_SKIP_CC_SWITCH_SYNC |
false |
跳过启动同步(开发调试用)Skip startup sync (for development) | |||
CC_SWITCH_SETTINGS_PATH |
~/.cc-switch/settings.json |
cc switch 配置文件路径Path to cc switch settings | |||
CC_SWITCH_DB_PATH |
~/.cc-switch/cc-switch.db |
cc switch 数据库路径Path to cc switch database | |||
CODEX_CONFIG_PATH |
~/.codex/config.toml |
Codex 配置文件路径Path to local Codex config |
~/.cc-switch/settings.json、~/.cc-switch/cc-switch.db、~/.codex/config.toml
Verify these files exist: ~/.cc-switch/settings.json, ~/.cc-switch/cc-switch.db, ~/.codex/config.toml
./ccmimolink --sync-only,然后重启 cc switch。
Run ./ccmimolink --sync-only again, then restart cc switch.