Hachimi Cloud HACHIMI
CLOUD哈基米云
Configuration Guide配置指南

Wire up GPT & Grok in minutes. 几分钟接入 GPT & Grok。

Connect OpenCode, Codex, and Claude Code to Hachimi Cloud through one OpenAI-compatible endpoint — then cut your token bill. 通过一个 OpenAI 兼容端点,将 OpenCode、Codex 和 Claude Code 接入 Hachimi Cloud,再顺手省下 token 开销。

OpenAI-compatible GPT · Grok EN / 中文

01Available Models可用模型

GPT — OpenAI models.GPT — OpenAI 模型。

Model Context上下文 Output输出
gpt-6-astra GPT-6-Astra400K128K
gpt-6-sol GPT-6-Sol400K128K
gpt-6-luna GPT-6-Luna400K128K
codex-auto-review Codex Auto Review——

Context limits vary by model. All GPT models pass store: false to prevent API-side conversation storage.上下文上限因模型而异。所有 GPT 模型均设置 store: false 以阻止 API 端存储对话。

Grok — xAI models.Grok — xAI 模型。

Model Context上下文 Output输出
grok-4.6 Grok-4.6——

02Pricing定价

Pay per token. Prices shown per 1M tokens; GPT rates are in USD ($) and Grok rates remain in CNY (¥).按 token 计费,下表价格均为每 100 万 tokens(1M);GPT 价格以 美元($)计,Grok 价格仍按人民币(¥)计。

Model Input输入 Output输出 Cache write (5m)缓存写入(5m)? Cache read缓存读取?
gpt-6-astra $5 $25 $6.25 $0.5
gpt-6-sol $0.5 $2.5 $0.625 $0.05
gpt-6-luna $0.05 $0.25 $0.0625 $0.005
grok-4.6 ¥0.3 ¥0.9 ¥0 (Free) ¥0.065

03Connect to Hachimi Cloud接入 Hachimi Cloud

Recommended: Use CC Switch — a cross-platform desktop app that configures OpenCode, Codex, and Claude Code in one click.推荐方式:使用 CC Switch —— 跨平台桌面工具,一键配置 OpenCode、Codex 和 Claude Code。

  • Base URL: https://api.hachimi.cloud/v1
  • API Key: your Hachimi Cloud key你的 Hachimi Cloud 密钥
  • Base URL: https://api.hachimi.cloud
  • API Key: your Hachimi Cloud key你的 Hachimi Cloud 密钥

Links:链接: ccswitch.io · GitHub

Manual Configuration手动配置

Config file:配置文件: ~/.codex/config.toml

model_provider = "OpenAI"
model = "gpt-6-astra"
web_search = "live"
model_reasoning_effort = "medium"

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.hachimi.cloud/v1"
wire_api = "responses"
requires_openai_auth = true
supports_websockets = true
experimental_bearer_token = "sk-your-api-key-here"
WebSocket — enabled by default with supports_websockets = true inside the provider block (not at the top of the file). If the connection is unstable — reconnect loops, mid-turn drops — set it to false and fully restart Codex to fall back to HTTP/SSE. WebSocket — 默认在提供商配置块中开启 supports_websockets = true(不要写在文件顶层)。如果连接不稳定(反复重连、中途断开),把它改成 false 并完全重启 Codex,即可回退到 HTTP/SSE。
⚠️ Web search — model_provider must be OpenAI (capital O) and web_search = "live". Using hachimi, custom, or lowercase openai can leave chat working while search never hits /v1/alpha/search. If the dashboard “Use Key” snippet omits web_search, add it yourself. Restart Codex fully after saving. Keep the Sub2API sk- on this provider — do not switch to the built-in lowercase openai provider. ⚠️ 联网搜索 — model_provider 必须是 OpenAI(注意大小写),并设置 web_search = "live"。写成 hachimi、custom 或小写 openai 时,对话可能正常,但不会调用 /v1/alpha/search。后台「一键使用」若未带 web_search,请自行补上。保存后请完全退出并重启 Codex。密钥继续用上面的 Sub2API sk-,不要改成内置小写 openai。

After saving, restart Codex CLI. The model name at the top should reflect your config.保存后重启 Codex CLI,顶部的模型名应显示为你的配置。

Config file:配置文件: ~/.config/opencode/opencode.json

{
  "provider": {
    "hachimi-cloud": {
      "options": {
        "baseURL": "https://api.hachimi.cloud/v1",
        "apiKey": "sk-your-api-key-here",
        "store": false
      },
      "models": {
        "gpt-6-astra": {
          "name": "GPT-6-Astra",
          "limit": { "context": 400000, "output": 128000 },
          "variants": {
            "low": { "reasoningEffort": "low" },
            "medium": { "reasoningEffort": "medium" },
            "high": { "reasoningEffort": "high" },
            "xhigh": { "reasoningEffort": "xhigh" },
            "max": { "reasoningEffort": "max" }
          }
        },
        "gpt-6-sol": {
          "name": "GPT-6-Sol",
          "limit": { "context": 400000, "output": 128000 },
          "variants": {
            "low": { "reasoningEffort": "low" },
            "medium": { "reasoningEffort": "medium" },
            "high": { "reasoningEffort": "high" },
            "xhigh": { "reasoningEffort": "xhigh" },
            "max": { "reasoningEffort": "max" }
          }
        },
        "gpt-6-luna": {
          "name": "GPT-6-Luna",
          "limit": { "context": 400000, "output": 128000 },
          "variants": {
            "low": { "reasoningEffort": "low" },
            "medium": { "reasoningEffort": "medium" },
            "high": { "reasoningEffort": "high" },
            "xhigh": { "reasoningEffort": "xhigh" },
            "max": { "reasoningEffort": "max" }
          }
        },
        "codex-auto-review": {
          "name": "Codex Auto Review"
        },
        "grok-4.6": {
          "name": "Grok-4.6"
        }
      }
    }
  },
  "plugin": [
    "@tarquinen/opencode-dcp@latest"
  ]
}

To use GPT as the default model:将 GPT 设为默认模型:

{
  "model": "hachimi-cloud/gpt-6-sol",
  "small_model": "hachimi-cloud/gpt-6-luna"
}

Run opencode and use /model to switch.运行 opencode,使用 /model 命令切换模型。

Config file:配置文件: ~/.claude/settings.json (global)

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-api-key-here",
    "ANTHROPIC_BASE_URL": "https://api.hachimi.cloud",
    "ANTHROPIC_MODEL": "grok-4.6"
  }
}
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-api-key-here",
    "ANTHROPIC_BASE_URL": "https://api.hachimi.cloud",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-6-luna",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME": "GPT-6-Luna",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "gpt-6-astra",
    "ANTHROPIC_DEFAULT_OPUS_MODEL_NAME": "GPT-6-Astra",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-6-sol",
    "ANTHROPIC_DEFAULT_SONNET_MODEL_NAME": "GPT-6-Sol",
    "ANTHROPIC_MODEL": "gpt-6-sol"
  }
}

Run /status in Claude Code to verify the active route.在 Claude Code 中运行 /status 验证当前路由。

Tip — paste any config snippet above into your coding agent chat and say "apply this to my setup" — it handles the rest.提示 — 把上面的配置片段粘贴给你的 AI 编程助手,说"帮我完成配置"即可。

04Save 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 时机

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:常用斜杠命令:

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
Codexexplorer
Claude Codeexplore

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/grok-4.6"
    }
  }
}

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 = "grok-4.6"
model_reasoning_effort = "low"
sandbox_mode = "read-only"
developer_instructions = """
Stay in exploration mode. Cite files and symbols; don't propose fixes.
"""
Tip — keep the subagent read-only and ask it to return just file paths, symbols, and line ranges. The main agent still reads each file before editing.提示 — 让子代理保持只读,只返回文件路径、符号和行号范围。主代理在改动前仍需自行通读相关文件。