Connect Codex to Hachimi Cloud. 用 Codex 接入哈基米云。
Use CC Switch to connect Codex to Hachimi Cloud’s GPT models. 通过 CC Switch 配置 Codex,接入哈基米云的 GPT 模型。
01Models & Pricing模型与定价
Prices in CNY (¥) per 1M tokens.价格以人民币(¥)/百万 Token计。
| Model模型 | Input输入 | Output输出 | Cache write (5m)缓存写入(5m)? | Cache read缓存读取? |
|---|---|---|---|---|
gpt-6.2-astra |
¥3.2 | ¥12 | ¥0 | ¥0.16 |
gpt-6.2-sol |
¥0.5 | ¥2.5 | ¥0 | ¥0.05 |
gpt-6.1-terra |
¥0.25 | ¥1.25 | ¥0 | ¥0.025 |
gpt-6-luna / codex-auto-review |
¥0.05 | ¥0.25 | ¥0 | ¥0.005 |
Note: The site displays the $ currency symbol, but top-ups are credited 1:1 in CNY — all pricing is actually in CNY (¥).注:站内显示的货币符号为 $,但人民币按 1:1 充值计入,实际均为人民币(¥)计价。
02Codex quick startCodex 快速开始
Recommended setup with CC Switch推荐用 CC Switch 配置
Download CC Switch下载 CC Switch
Choose the installer for macOS, Windows, or Linux. After installing, open the Codex panel in CC Switch. 选择 macOS、Windows 或 Linux 的安装包,安装后打开 CC Switch 的 Codex 面板。
- Select Codex in the left sidebar. Click Add Provider in the top right and choose Custom Configuration. 在左侧选择 Codex,点击右上角的「添加供应商」,然后选择「自定义配置」。
-
Fill in the provider form.
在供应商表单中填写以下字段。
- Name名称
Hachimi Cloud - API Key Your Hachimi Cloud API key你的哈基米云 API Key
- API Request URLAPI 请求地址
https://api.hachimi.cloud/v1 - Default Model默认模型
gpt-6.2-sol
- Name名称
-
Scroll to config.toml (TOML), set
model_reasoning_effort = "high"at the top level, and check Enable remote compaction at the top right of the editor. 向下滚动到 config.toml (TOML) 区域,将顶层的推理档位设为model_reasoning_effort = "high",并勾选编辑器右上方的「启用远程压缩」。 -
Optional. Check 1M Context Window if your model supports it. To use WebSocket in Direct mode, set
supports_websockets = truein the Hachimi Cloud provider section of the editor. 可选。模型支持时,可勾选「1M 上下文窗口」。如需在直连模式使用 WebSocket,将编辑器中当前供应商小节下的supports_websockets设为true。 - Click Add, switch to Hachimi Cloud in Direct mode, then fully quit and reopen Codex. 点击「添加」,回到「直连」列表并切换到 Hachimi Cloud,然后完全退出并重新打开 Codex。
Optional if you have a ChatGPT account. To keep access to features such as official plugins and remote control from your phone, complete these two steps before switching to Hachimi Cloud. 有 ChatGPT 账号时可选。若想继续使用账号可用的官方插件和手机远程操作等功能,请先完成下面两步,再切换到 Hachimi Cloud。
- Choose OpenAI Official in CC Switch, then sign in to your ChatGPT account in Codex. 在 CC Switch 中切换到 OpenAI Official,然后在 Codex 中登录你的 ChatGPT 账号。
- In CC Switch Settings, under Codex, turn on Keep official login for direct switches. 在 CC Switch 的「设置 → 应用配置 → Codex」中开启「非接管切换时保留官方登录」。
Codex configuration referenceCodex 配置参考 config.toml
model_provider = "OpenAI"
model = "gpt-6.2-sol"
web_search = "live"
model_reasoning_effort = "high"
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.hachimi.cloud/v1"
model_catalog_url = "https://api.hachimi.cloud/v1/models"
wire_api = "responses"
requires_openai_auth = false
supports_websockets = false
03Save Tokens省 Token 技巧
Big context windows are convenient, but every turn re-sends the whole conversation. These three habits keep your context lean and your bill low.大上下文很方便,但每一轮都会重发整段对话。下面三个习惯能让上下文保持精简、账单更低。
Compact at the right moment把握 Compact 时机
- Compact proactively as you near the context limit — don't wait for auto-compact to truncate mid-task and lose the thread.
- 主动在接近上下文上限前 compact —— 别等自动 compact 在关键处截断、丢失思路。
- Before compacting, have the model pin the key conclusions (current goal, confirmed facts, next step), then compress. Compaction is lossy.
- compact 前先让模型固化关键结论(当前目标、已确认事实、下一步),再压缩。压缩是有损的。
- Work in phases: when one sub-task is done and the next is unrelated, compact to drop now-irrelevant tool output.
- 分阶段推进:一个子任务完成、下一个无关时就 compact,丢掉已无关的工具输出。
- Both Claude Code and OpenCode expose
/compact; trigger it yourself rather than relying on the automatic threshold. - Claude Code 与 OpenCode 都提供
/compact;主动触发,而不是依赖自动阈值。
DCP — Dynamic Context PruningDCP — 动态上下文裁剪
DCP is an OpenCode plugin that automatically shrinks context — replacing stale content with placeholders before each request, without ever modifying your session history. It compresses closed spans into technical summaries, deduplicates repeated tool calls, and purges errored tool inputs.DCP 是一个 OpenCode 插件,在每次请求前用占位符替换陈旧内容来自动压缩上下文,且从不改写你的会话历史。它把已结束的片段压缩成技术摘要、去重重复的工具调用、清理报错工具的输入。
opencode plugin @tarquinen/opencode-dcp@latest --global
Config lives in ~/.config/opencode/dcp.jsonc (global) or .opencode/dcp.jsonc (project). Set compress.maxContextLimit / minContextLimit as a percentage of the model's context window so the thresholds auto-scale:配置位于 ~/.config/opencode/dcp.jsonc(全局)或 .opencode/dcp.jsonc(项目级)。把 compress.maxContextLimit / minContextLimit 设为模型上下文窗口的百分比,阈值即可按模型自动缩放:
{
"enabled": true,
"compress": {
"mode": "range",
"maxContextLimit": "70%",
"minContextLimit": "30%"
}
}
Handy slash commands:常用斜杠命令:
/dcp context— token breakdown for the current session + how much was saved当前会话的 token 明细 + 已节省量/dcp compress [focus]— trigger one compression pass手动触发一次压缩/dcp sweep [n]— prune tool calls since the last user message裁剪自上条用户消息以来的工具调用/dcp manual [on|off]— toggle autonomous context management开关自动上下文管理
Delegate exploration to a subagent把探索交给子代理
Read-only codebase exploration is the biggest token sink in the main thread. Hand searching and file-reading to a cheaper explore subagent, and let the main agent read only the files it will actually edit. The exploration tokens stay in the subagent's context, not yours.只读的代码库探索是主线程里最大的 token 消耗。把检索和读文件交给更便宜的探索子代理,主代理只读真正要改的文件。探索产生的 token 留在子代理的上下文里,而不进入你的主上下文。
| Tool | Explore subagent探索子代理 |
|---|---|
| OpenCode | @explore |
| Codex | explorer |
| Claude Code | explore |
When to delegate: finding a symbol's usages across many files, mapping a subsystem, locating the owner file for unfamiliar behavior, or gathering root-cause evidence — anything where you only need the conclusion, not the raw file dumps.何时委派:跨多文件查找符号用法、梳理子系统、定位陌生行为的归属文件、收集根因证据 —— 凡是你只需要结论、不需要原始文件内容的场景。
Make it automatic — write the delegation policy into your rules file so the main agent always offloads exploration: Claude Code reads ~/.claude/CLAUDE.md (or per-agent .claude/agents/*.md), while OpenCode and Codex read AGENTS.md. Spell out when to delegate and demand locator-only output (path · symbol · line range · one-line reason) so the subagent never dumps whole files back.让它自动发生 — 把「委派探索」的规则写进你的规则文件,主代理就会始终把探索外包出去:Claude Code 读取 ~/.claude/CLAUDE.md(或单个 .claude/agents/*.md),OpenCode 与 Codex 读取 AGENTS.md。在规则里写清何时委派、并要求只返回定位信息(路径 · 符号 · 行号范围 · 一句话理由),子代理就不会把整段文件回灌给你。
Pin a cheaper model — all three let you set the subagent's model explicitly. Point the explorer at a small, cheap model while the main agent keeps a stronger one — exploration runs cost a fraction:指定更便宜的模型 — 三家都支持显式设置子代理的模型。让探索子代理用小而便宜的模型,主代理仍用更强的模型 —— 探索的开销可以低一个量级:
.claude/agents/explore.md
---
name: explore
description: Read-only codebase exploration (locator mode)
tools: Read, Grep, Glob
model: haiku
---
Return only: file path, symbol, line range, one-line reason.
~/.config/opencode/opencode.json
{
"agent": {
"explore": {
"mode": "subagent",
"model": "hachimi-cloud/gpt-6.1-terra"
}
}
}
Or run exploration for free with one of OpenCode Zen's built-in free models (rotating — e.g. opencode/deepseek-v4-flash-free) so your explore agent costs nothing:或者用 OpenCode Zen 自带的免费模型来跑探索(会轮换 —— 如 opencode/deepseek-v4-flash-free),让探索子代理零成本:
{
"agent": {
"explore": {
"mode": "subagent",
"model": "opencode/deepseek-v4-flash-free"
}
}
}
.codex/agents/explorer.toml
name = "explorer"
description = "Read-only codebase explorer for gathering evidence."
model = "gpt-6.1-terra"
model_reasoning_effort = "low"
sandbox_mode = "read-only"
developer_instructions = """
Stay in exploration mode. Cite files and symbols; don't propose fixes.
"""