<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes)]]></title><description><![CDATA[<p dir="auto"><img src="https://upload.lcz.me/uploads/5330a2dd-abd7-4ab7-a386-8828c90467aa.jpg" alt="5_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/d2deab68-36ad-4c62-b7b2-44ffe0988298.jpg" alt="6_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/092e4fa4-8037-49c4-a2dd-daf3aee8d1d9.jpg" alt="1_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/73761a52-b66a-42a4-8d37-ccefbaec0e1c.jpg" alt="2_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/4488bc1c-fd13-4de8-a00b-44030ac975c9.jpg" alt="3_compressed.jpg" class=" img-fluid img-markdown" /> <img src="https://upload.lcz.me/uploads/029ea8de-9060-422d-ac45-800ff12a0cdd.jpg" alt="4_compressed.jpg" class=" img-fluid img-markdown" /> 用codex實作成功後 請他整理的~分享給大家<br />
截至 2026-05-23，Hermes 官方文件已明確支援：<br />
xai-oauth：SuperGrok / X Premium+<br />
openai-codex：ChatGPT OAuth<br />
anthropic：Claude OAuth<br />
但要注意一個關鍵差異：<br />
官方文件寫的是 Claude OAuth 需要 Claude Max + extra usage credits，不是 Claude Pro。<br />
Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記<br />
更新日期：2026-05-23</p>
<p dir="auto">以下本篇開始<br />
Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記<br />
(chatgpt plus可調用API給hermes)平常用qwen3.6 27b 遇到坎改codex,<br />
這篇是我在 Windows 上實際把 Hermes 串上本地 llama.cpp Qwen 模型、OpenAI Codex OAuth，以及 Telegram Gateway 的完整紀錄。主題分成兩段：</p>
<p dir="auto">怎麼把 Codex 的 OAuth 設進 Hermes<br />
串完之後，怎麼跟本地 Qwen、Telegram 一起穩定工作<br />
重點不是只有「能不能跑」，而是把中間最容易卡住的地方也一起講清楚。</p>
<p dir="auto">這篇最核心要解的是什麼<br />
我一開始真正要做的事其實很單純：</p>
<p dir="auto">把 ChatGPT / Codex 的 OAuth 接進 Hermes<br />
然後讓 Hermes 能同時做到：</p>
<p dir="auto">提供 Codex 模型給 Hermes 自己使用<br />
提供本地 OpenAI-compatible proxy 給其他工具使用<br />
保留本地 Qwen，不要被 Codex 蓋掉<br />
讓 Telegram 裡能手動切換本地模型和 Codex<br />
所以如果你只是想看「Codex OAuth 怎麼設進 Hermes」，先看下面這段就夠。</p>
<p dir="auto">最短教學：怎麼把 Codex OAuth 設進 Hermes</p>
<ol>
<li>先確認 Hermes 版本<br />
至少先升到較新的版本，我這次成功環境是：</li>
</ol>
<p dir="auto">Hermes v0.14.0<br />
可以先查：</p>
<p dir="auto">hermes --version<br />
2. 用 Hermes 登入 OpenAI Codex<br />
最直接有兩種做法。</p>
<p dir="auto">方法 A：</p>
<p dir="auto">hermes model<br />
在 provider 清單裡選：</p>
<p dir="auto">OpenAI Codex<br />
方法 B：</p>
<p dir="auto">hermes auth add openai-codex<br />
3. 登入完先查狀態<br />
hermes auth status openai-codex<br />
hermes status<br />
正常時會看到：</p>
<p dir="auto">OpenAI Codex  logged in<br />
4. 啟動 Hermes Proxy<br />
hermes proxy start --provider openai-codex<br />
成功後通常會提供：</p>
<p dir="auto"><a href="http://127.0.0.1:8645/v1" rel="nofollow ugc">http://127.0.0.1:8645/v1</a><br />
5. 驗證 Proxy<br />
curl.exe -i -H "Authorization: Bearer sk-unused" <a href="http://127.0.0.1:8645/health" rel="nofollow ugc">http://127.0.0.1:8645/health</a><br />
curl.exe -i -H "Authorization: Bearer sk-unused" <a href="http://127.0.0.1:8645/v1/models" rel="nofollow ugc">http://127.0.0.1:8645/v1/models</a><br />
如果成功，代表：</p>
<p dir="auto">Hermes 已拿到 Codex OAuth<br />
Hermes Proxy 已能代轉給 Codex<br />
6. 接到其他工具<br />
其他支援 OpenAI-compatible 的工具就填：</p>
<p dir="auto">Base URL: <a href="http://127.0.0.1:8645/v1" rel="nofollow ugc">http://127.0.0.1:8645/v1</a><br />
API Key: 任意非空字串，例如 sk-unused<br />
Model: gpt-5.5<br />
目標<br />
我最後要達成的是這個完整配置：</p>
<p dir="auto">本地主模型：Qwen3.6-27B-Q4_K_M-mtp.gguf<br />
本地推理：llama-server 跑在 <a href="http://127.0.0.1:8080/v1" rel="nofollow ugc">http://127.0.0.1:8080/v1</a><br />
Hermes Gateway：接 Telegram<br />
Hermes Proxy：提供 OpenAI-compatible 端點給 Codex OAuth<br />
Telegram 內可隨時切換：<br />
/qwen<br />
/qwenmtp<br />
/codex<br />
我的環境<br />
Windows 11<br />
Hermes v0.14.0<br />
llama.cpp / llama-server<br />
本地模型：Qwen3.6-27B-Q4_K_M-mtp.gguf<br />
最後成功的架構</p>
<ol>
<li>本地 Qwen<br />
llama-server 提供：</li>
</ol>
<p dir="auto"><a href="http://127.0.0.1:8080/v1" rel="nofollow ugc">http://127.0.0.1:8080/v1</a><br />
Hermes 的全域預設模型最後設成：</p>
<p dir="auto">model:<br />
default: Qwen3.6-27B-Q4_K_M-mtp.gguf<br />
provider: custom:local-q4k_m-(主模型)<br />
base_url: <a href="http://localhost:8080/v1" rel="nofollow ugc">http://localhost:8080/v1</a><br />
這樣 Telegram 開新 session 或 /new 之後，預設會回到本地 Qwen，不會誤跳到 Codex。</p>
<ol start="2">
<li>Codex Proxy<br />
Hermes Proxy 成功後提供：</li>
</ol>
<p dir="auto"><a href="http://127.0.0.1:8645/v1" rel="nofollow ugc">http://127.0.0.1:8645/v1</a><br />
工具端要填：</p>
<p dir="auto">Provider: OpenAI-compatible / Custom OpenAI<br />
Base URL: <a href="http://127.0.0.1:8645/v1" rel="nofollow ugc">http://127.0.0.1:8645/v1</a><br />
API Key: 任意非空字串，例如 sk-unused<br />
Model: gpt-5.5<br />
一開始遇到的坑<br />
坑 1：Hermes 升級後，openai-codex proxy 不是直接可用<br />
雖然 Hermes 新版已經有 OpenAI Codex provider，但當時 proxy 這條沒有完整對上，所以需要補上 openai-codex adapter 才能讓：</p>
<p dir="auto">hermes proxy start --provider openai-codex<br />
正常工作。</p>
<p dir="auto">補完後可以驗證：</p>
<p dir="auto">curl.exe -i -H "Authorization: Bearer sk-unused" <a href="http://127.0.0.1:8645/health" rel="nofollow ugc">http://127.0.0.1:8645/health</a><br />
curl.exe -i -H "Authorization: Bearer sk-unused" <a href="http://127.0.0.1:8645/v1/models" rel="nofollow ugc">http://127.0.0.1:8645/v1/models</a><br />
/health 回 authenticated: true，/v1/models 能列出 gpt-5.5 才算通。</p>
<p dir="auto">坑 2：Telegram /new 之後一直跳回 Codex<br />
這不是 Telegram 壞掉，而是 Hermes 全域預設模型原本還是：</p>
<p dir="auto">gpt-5.5 / openai-codex<br />
所以：</p>
<p dir="auto">/qwenmtp 只是 session only<br />
一旦 /new<br />
就又回到全域預設<br />
解法是把全域預設改回本地 Qwen MTP。</p>
<p dir="auto">坑 3：/codex 顯示切換成功，但一問就 429<br />
這個最容易誤判。</p>
<p dir="auto">一開始看到：</p>
<p dir="auto">Model switched to gpt-5.5<br />
Provider: OpenAI Codex<br />
很像成功，但實際一發問就出現：</p>
<p dir="auto">The model provider is rate-limiting requests.<br />
HTTP 429: The usage limit has been reached<br />
一開始以為是：</p>
<p dir="auto">Hermes 選錯 credential<br />
或舊 token 被標成 exhausted<br />
後來實際解 JWT 才發現真正原因。</p>
<p dir="auto">最關鍵的真相：Hermes 當時吃到的是 free token，不是 Plus<br />
雖然我登入的 ChatGPT 帳號本身是 Plus，但 Hermes auth add openai-codex 當時拿到的 OAuth token，JWT 內容顯示：</p>
<p dir="auto">chatgpt_plan_type = free<br />
這就是為什麼 Telegram 裡明明只問一句話，也會直接被上游 429。</p>
<p dir="auto">換句話說，問題不是「一句話用爆額度」，而是：</p>
<p dir="auto">Hermes 那條 OAuth session 根本不是可用的 Plus/Codex 身分<br />
上游直接把那筆 session 視為 free path<br />
為什麼會這樣<br />
這次排查後發現，系統其實有兩套不同來源的憑證：</p>
<ol>
<li>~/.codex/auth.json<br />
這是 Codex CLI 自己的登入狀態。我的這份內容解出來是：</li>
</ol>
<p dir="auto">plan_type = plus<br />
2. ~/AppData/Local/hermes/auth.json<br />
這是 Hermes 自己維護的 OpenAI Codex OAuth 狀態。當時 Hermes 裡那份 token 解出來卻是：</p>
<p dir="auto">plan_type = free<br />
也就是說：</p>
<p dir="auto">Codex CLI 是 Plus<br />
Hermes OAuth 卻不是 Plus<br />
所以 Telegram Gateway 走 Hermes 那套時，當然就一直 429。</p>
<p dir="auto">真正修好的方法<br />
步驟 1：清掉 Hermes 裡錯的 free Codex 憑證<br />
先備份，再移除已經被判定 free / usage_limit_reached 的 openai-codex credential。</p>
<p dir="auto">步驟 2：不要再用錯的 device-code session<br />
這次最重要的觀察是：</p>
<p dir="auto">hermes auth add openai-codex<br />
走的是 Hermes 自己的 device-code 流程。</p>
<p dir="auto">但 ~/.codex/auth.json 那份其實已經是可用的 Plus token。</p>
<p dir="auto">步驟 3：把 ~/.codex/auth.json 的 Plus token 匯入 Hermes auth store<br />
也就是讓 Hermes 不再用那條 free 的 OAuth session，而改吃 Codex CLI 那份已確認是 plus 的 token。</p>
<p dir="auto">修完後再驗證 Hermes credential pool，確認只剩一筆：</p>
<p dir="auto">openai-codex<br />
#1 device_code oauth device_code<br />
而且解 token 後是：</p>
<p dir="auto">plan_type = plus<br />
步驟 4：重啟 Gateway<br />
讓 Telegram Gateway 重新載入新的 Codex credential pool。</p>
<p dir="auto">Telegram 最後怎麼用<br />
本地 Qwen<br />
/qwen<br />
或</p>
<p dir="auto">/qwenmtp<br />
Codex<br />
/codex<br />
注意：/codex 要單獨一則訊息送出，不要寫成：</p>
<p dir="auto">/codex 你目前什麼模型<br />
因為 Hermes 會把後面那串當成模型名稱的一部分，然後報：</p>
<p dir="auto">Error: Model names cannot contain spaces.<br />
正確做法是兩則：</p>
<p dir="auto">/codex<br />
等看到切換成功後，再送：</p>
<p dir="auto">你目前什麼模型？<br />
我最後保留的策略<br />
我沒有把全域預設改成 Codex，而是保留：</p>
<p dir="auto">全域預設：本地 Qwen MTP<br />
需要雲端時：手動 /codex<br />
這樣比較穩，因為：</p>
<p dir="auto">/new 後不會掉回雲端<br />
本地模型一定可用<br />
Codex 有狀況時不會拖垮 Telegram 整體可用性<br />
啟動腳本最後怎麼改<br />
我的 start-all.bat 最後改成這種思路：</p>
<p dir="auto">只重啟 llama-server<br />
Hermes Gateway 如果已在跑，就不要重複啟動<br />
Hermes Codex proxy 如果 8645 沒開，再補開<br />
保留 warmup 流程<br />
重點不是腳本長怎樣，而是避免每次都：</p>
<p dir="auto">把 Gateway 砍掉重開<br />
把正常的 proxy 狀態搞亂<br />
造成舊 session 和新 session 混在一起<br />
驗證清單<br />
如果你也要照這樣配，最後至少要確認這些：</p>
<p dir="auto">本地模型<br />
curl.exe -H "Authorization: Bearer 123" <a href="http://127.0.0.1:8080/v1/models" rel="nofollow ugc">http://127.0.0.1:8080/v1/models</a><br />
要能看到你的本地 gguf 模型。</p>
<p dir="auto">Hermes Gateway<br />
hermes gateway status<br />
要顯示 running。</p>
<p dir="auto">Hermes Proxy<br />
curl.exe -i -H "Authorization: Bearer sk-unused" <a href="http://127.0.0.1:8645/health" rel="nofollow ugc">http://127.0.0.1:8645/health</a><br />
curl.exe -i -H "Authorization: Bearer sk-unused" <a href="http://127.0.0.1:8645/v1/models" rel="nofollow ugc">http://127.0.0.1:8645/v1/models</a><br />
要成功。</p>
<p dir="auto">Codex 身分不是 free<br />
這點超重要。不是只看「logged in」，而是要確認實際 token 對應的帳號身分不是 free。</p>
<p dir="auto">如果 Telegram 裡還是出現：</p>
<p dir="auto">The usage limit has been reached<br />
plan_type: free<br />
那就代表 Hermes 仍然沒吃到正確的 Plus/Codex token。</p>
<p dir="auto">結論<br />
這次最容易踩坑的地方，不是 Hermes 本身能不能接 Codex，而是：</p>
<p dir="auto">Hermes 的 Codex OAuth session<br />
不一定等於<br />
你 Codex CLI / ChatGPT 前端正在用的那個 Plus 帳號<br />
如果你看到：</p>
<p dir="auto">hermes auth status openai-codex 說 logged in<br />
/codex 也顯示切換成功<br />
但實際一問就 429<br />
不要只懷疑額度。</p>
<p dir="auto">先確認那份 token 真的是：</p>
<p dir="auto">plan_type = plus / pro<br />
這次真正修好的關鍵，就是把 Hermes 從錯的 free session，切回正確的 Plus token。</p>
<p dir="auto">補充<br />
如果你要讓 Telegram 長期穩定使用，我會建議：</p>
<p dir="auto">全域預設留本地 Qwen<br />
/codex 做按需切換<br />
啟動腳本不要每次暴力重開 Gateway<br />
所有修改前先備份 config.yaml、auth.json<br />
這樣真的省很多事。</p>
<p dir="auto">2026/7/10新增內容接gemini pro訂閱額度給herems調用,簡單教學文件,ai整理的</p>
<h1>Hermes Agent 接 Gemini Pro 與 OpenAI Codex 訂閱 OAuth：不是 MCP，是本機 OpenAI-compatible Proxy</h1>
<p dir="auto">這篇記錄我這次把 Gemini Pro 訂閱帳號接進 Hermes Agent 的做法。</p>
<p dir="auto">先講結論：這條路線不是用 Hermes 的 MCP，也不是只讓 Hermes 去呼叫 <code>agy</code> CLI。實際跑通的是：</p>
<pre><code class="language-text">Google OAuth / Antigravity
        ↓
CLIProxyAPI 本機代理
        ↓
http://127.0.0.1:8317/v1  OpenAI-compatible API
        ↓
Hermes custom provider
</code></pre>
<p dir="auto">也就是把 Gemini/Antigravity 的 OAuth 能力包成一個本機 <code>/v1</code> API，Hermes 再把它當成 OpenAI-compatible provider 使用。</p>
<h2>成功後的狀態</h2>
<p dir="auto">本機跑起來後會有兩個重要服務：</p>
<pre><code class="language-text">127.0.0.1:8317  CLIProxyAPI，負責 Gemini OAuth proxy
127.0.0.1:8080  原本本機 Qwen / llama-server
</code></pre>
<p dir="auto">Hermes 裡面則可以同時保留兩個 provider：</p>
<pre><code class="language-yaml">custom_providers:
  - name: gemini-proxy
    base_url: http://127.0.0.1:8317/v1
    key_env: CLIPROXY_API_KEY
    api_mode: chat_completions
    models:
      gemini-pro-agent:
        context_length: 1048576
      gemini-3.1-pro-low:
        context_length: 1048576
      gemini-3-flash-agent:
        context_length: 1048576
      gemini-3-flash:
        context_length: 1048576
      gemini-3.5-flash-low:
        context_length: 1048576
      gemini-3.5-flash-extra-low:
        context_length: 1048576

  - name: qwen-local
    base_url: http://127.0.0.1:8080/v1
    api_mode: chat_completions
    models:
      Qwopus3.6-27B-v2-MTP-Q4_K_M.gguf:
        context_length: 131072
</code></pre>
<p dir="auto">目前我自己的 Hermes 主模型可以這樣設：</p>
<pre><code class="language-yaml">model:
  provider: custom:gemini-proxy
  default: gemini-3.5-flash-extra-low
  context_length: 1048576
</code></pre>
<p dir="auto">如果要改回 Gemini Pro agent，也可以改成：</p>
<pre><code class="language-yaml">model:
  provider: custom:gemini-proxy
  default: gemini-pro-agent
  context_length: 1048576
</code></pre>
<h2>安裝 CLIProxyAPI</h2>
<p dir="auto">我把它放在 Hermes 目錄底下：</p>
<pre><code class="language-bash">mkdir -p ~/.hermes/cli-proxy/bin
cd ~/.hermes/cli-proxy
</code></pre>
<p dir="auto">下載 CLIProxyAPI Linux amd64 release，例如我這次用的是：</p>
<pre><code class="language-text">CLIProxyAPI_7.2.58_linux_amd64.tar.gz
</code></pre>
<p dir="auto">解開後會有：</p>
<pre><code class="language-text">~/.hermes/cli-proxy/bin/cli-proxy-api
~/.hermes/cli-proxy/bin/config.example.yaml
</code></pre>
<p dir="auto">確認 binary 可以執行：</p>
<pre><code class="language-bash">chmod +x ~/.hermes/cli-proxy/bin/cli-proxy-api
~/.hermes/cli-proxy/bin/cli-proxy-api --help
</code></pre>
<h2>建立 proxy config</h2>
<p dir="auto">我用的設定大概是這樣，API key 請自己產生，不要貼真值：</p>
<pre><code class="language-yaml">host: 127.0.0.1
port: 8317
api_keys:
  - "replace-with-your-local-random-key"
auth_dir: /home/YOUR_USER/.hermes/cli-proxy/auth
log_dir: /home/YOUR_USER/.hermes/cli-proxy/logs
static_dir: /home/YOUR_USER/.hermes/cli-proxy/static
</code></pre>
<p dir="auto">我另外把 key 放進 Hermes 的 <code>.env</code>：</p>
<pre><code class="language-bash">CLIPROXY_API_KEY=replace-with-your-local-random-key
</code></pre>
<p dir="auto">這樣 Hermes config 裡就可以用：</p>
<pre><code class="language-yaml">key_env: CLIPROXY_API_KEY
</code></pre>
<p dir="auto">不要把 proxy API key 寫進分享文、git repo 或截圖。</p>
<h2>Google OAuth</h2>
<p dir="auto">這一步是關鍵。</p>
<p dir="auto">CLIProxyAPI 啟動後，照它提供的 login/OAuth flow 讓瀏覽器完成 Google 授權。授權成功後，<code>auth_dir</code> 裡會出現類似：</p>
<pre><code class="language-text">~/.hermes/cli-proxy/auth/antigravity-&lt;your-google-account&gt;.json
</code></pre>
<p dir="auto">這個檔案是 OAuth 憑證，權限建議至少設成：</p>
<pre><code class="language-bash">chmod 600 ~/.hermes/cli-proxy/auth/*.json
</code></pre>
<p dir="auto">我這台是透過遠端機器操作，所以 OAuth 頁面需要用 SSH tunnel 或可以開瀏覽器的方式完成。這也是很多人會卡住的地方：不是 Hermes 不能接，而是 OAuth callback 沒有正確回到本機 proxy。</p>
<h2>用 PM2 常駐 CLIProxyAPI</h2>
<p dir="auto">我的 <code>pm2</code> 不在系統 PATH 裡，所以用完整路徑：</p>
<pre><code class="language-bash">~/.hermes/node/bin/pm2 start ~/.hermes/cli-proxy/bin/cli-proxy-api \
  --name cli-proxy-api \
  -- -config ~/.hermes/cli-proxy/config.yaml

~/.hermes/node/bin/pm2 save
</code></pre>
<p dir="auto">確認它有活著：</p>
<pre><code class="language-bash">~/.hermes/node/bin/pm2 status
ss -ltnp | grep 8317
</code></pre>
<p dir="auto">應該看到：</p>
<pre><code class="language-text">cli-proxy-api  online
127.0.0.1:8317 LISTEN
</code></pre>
<h2>測試 proxy</h2>
<p dir="auto">先測 <code>/v1/models</code>：</p>
<pre><code class="language-bash">curl -s http://127.0.0.1:8317/v1/models \
  -H "Authorization: Bearer $CLIPROXY_API_KEY"
</code></pre>
<p dir="auto">我這邊能看到的模型包含：</p>
<pre><code class="language-text">gemini-pro-agent
gemini-3.1-pro-low
gemini-3-flash-agent
gemini-3-flash
gemini-3.5-flash-low
gemini-3.5-flash-extra-low
</code></pre>
<p dir="auto">再測 chat completions：</p>
<pre><code class="language-bash">curl -s http://127.0.0.1:8317/v1/chat/completions \
  -H "Authorization: Bearer $CLIPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-pro-agent",
    "messages": [
      {"role": "user", "content": "Reply with exactly: Gemini proxy confirmed"}
    ]
  }'
</code></pre>
<p dir="auto">能正常回覆後，再接 Hermes。</p>
<h2>Hermes 設定 custom provider</h2>
<p dir="auto">在 Hermes 的 <code>config.yaml</code> 加上：</p>
<pre><code class="language-yaml">custom_providers:
  - name: gemini-proxy
    base_url: http://127.0.0.1:8317/v1
    key_env: CLIPROXY_API_KEY
    api_mode: chat_completions
    models:
      gemini-pro-agent:
        context_length: 1048576
      gemini-3.1-pro-low:
        context_length: 1048576
      gemini-3-flash-agent:
        context_length: 1048576
      gemini-3-flash:
        context_length: 1048576
      gemini-3.5-flash-low:
        context_length: 1048576
      gemini-3.5-flash-extra-low:
        context_length: 1048576
</code></pre>
<p dir="auto">主模型可以設：</p>
<pre><code class="language-yaml">model:
  provider: custom:gemini-proxy
  default: gemini-pro-agent
  context_length: 1048576
</code></pre>
<p dir="auto">或改成比較省的：</p>
<pre><code class="language-yaml">model:
  provider: custom:gemini-proxy
  default: gemini-3.5-flash-extra-low
  context_length: 1048576
</code></pre>
<p dir="auto">改完後重啟 Hermes gateway：</p>
<pre><code class="language-bash">systemctl --user restart hermes-gateway
systemctl --user is-active hermes-gateway
</code></pre>
<h2>Hermes 裡切換模型</h2>
<p dir="auto">在 Telegram / Hermes bot 裡可以用：</p>
<pre><code class="language-text">/model custom:gemini-proxy:gemini-pro-agent --global
/model custom:gemini-proxy:gemini-3.1-pro-low --global
/model custom:gemini-proxy:gemini-3.5-flash-low --global
/model custom:gemini-proxy:gemini-3.5-flash-extra-low --global
</code></pre>
<p dir="auto">切完建議開新 session：</p>
<pre><code class="language-text">/new
</code></pre>
<p dir="auto"><code>--global</code> 是改預設新 session。只想改目前 session，可以用 <code>--session</code>。</p>
<h2>接回原本 8080 Qwen</h2>
<p dir="auto">原本本機 Qwen 也可以保留成另一個 provider：</p>
<pre><code class="language-yaml">custom_providers:
  - name: qwen-local
    base_url: http://127.0.0.1:8080/v1
    api_mode: chat_completions
    models:
      Qwopus3.6-27B-v2-MTP-Q4_K_M.gguf:
        context_length: 131072
</code></pre>
<p dir="auto">要切回 Qwen：</p>
<pre><code class="language-text">/model custom:qwen-local:Qwopus3.6-27B-v2-MTP-Q4_K_M.gguf --global
/new
</code></pre>
<p dir="auto">前提是你的 llama-server / OpenAI-compatible Qwen server 已經在 <code>8080</code> 跑著。</p>
<p dir="auto">確認：</p>
<pre><code class="language-bash">ss -ltnp | grep 8080
</code></pre>
<h2>我這次踩到的坑</h2>
<h3>1. 一開始容易誤會成 MCP</h3>
<p dir="auto">Hermes 本來就可以用 MCP 去調外部工具，<code>agy</code> CLI 也可以透過 MCP/CLI 被呼叫。</p>
<p dir="auto">但這次要的是「把 Gemini Pro 訂閱 OAuth 當成 Hermes 的模型 provider」，不是「讓 Hermes 呼叫一個工具」。所以正確方向是 OpenAI-compatible local proxy。</p>
<p dir="auto">簡單判斷：</p>
<pre><code class="language-text">MCP / CLI tool：模型還是 Hermes 原本的模型，只是多一個工具可以叫
OpenAI-compatible proxy：Gemini 變成 Hermes 的模型本體
</code></pre>
<h3>2. <code>agy</code> 能跑，不代表 Hermes 直接吃得到 OAuth</h3>
<p dir="auto"><code>agy</code> 自己有 Google OAuth，但 Hermes 不會自動讀 <code>agy</code> 的登入狀態。中間需要一層 proxy，把 OAuth 模型包成 <code>/v1/chat/completions</code>。</p>
<p dir="auto">這就是 CLIProxyAPI 的角色。</p>
<h3>3. <code>pm2</code> 可能不在 PATH</h3>
<p dir="auto">我這台不能直接跑：</p>
<pre><code class="language-bash">pm2 status
</code></pre>
<p dir="auto">要用：</p>
<pre><code class="language-bash">~/.hermes/node/bin/pm2 status
</code></pre>
<p dir="auto">文章或 runbook 建議都寫完整路徑，少一個環境差異。</p>
<h3>4. OAuth callback 在遠端機器上會卡</h3>
<p dir="auto">如果是在 SSH server、遠端桌面、無頭環境上跑，Google OAuth 頁面開在你本機瀏覽器，但 callback 要回到遠端機器上的 proxy。</p>
<p dir="auto">解法通常是：</p>
<pre><code class="language-text">用 SSH tunnel 把 callback port 轉回遠端
或在遠端機器上直接完成瀏覽器授權
</code></pre>
<p dir="auto">授權成功的判斷不是「網頁看起來過了」，而是 <code>auth_dir</code> 裡真的出現 OAuth JSON。</p>
<h3>5. Hermes provider 名稱要寫完整</h3>
<p dir="auto">切模型時不是只打模型名，而是：</p>
<pre><code class="language-text">custom:&lt;provider-name&gt;:&lt;model-name&gt;
</code></pre>
<p dir="auto">例如：</p>
<pre><code class="language-text">/model custom:gemini-proxy:gemini-pro-agent --global
</code></pre>
<p dir="auto">少了 <code>custom:gemini-proxy:</code> 這段，Hermes 可能會找不到正確 provider。</p>
<h3>6. 不要把 key 和 OAuth JSON 放進文章</h3>
<p dir="auto">至少這幾個東西不能貼：</p>
<pre><code class="language-text">CLIPROXY_API_KEY 真值
~/.hermes/cli-proxy/api_key
~/.hermes/cli-proxy/auth/*.json
任何 Google OAuth token
</code></pre>
<p dir="auto">分享時用 placeholder 就好。</p>
<h2>最後驗證</h2>
<p dir="auto">我這次最後驗證了三件事：</p>
<pre><code class="language-text">1. CLIProxyAPI 在 127.0.0.1:8317 online
2. /v1/models 能列出 Gemini models
3. Hermes 可以用 custom:gemini-proxy 跑 Gemini，也可以切回 custom:qwen-local 的 8080 Qwen
</code></pre>
<p dir="auto">這樣 Hermes 就不是只能 MCP/CLI 調用 Gemini，而是可以把 Gemini Pro OAuth proxy 當成真正的模型 provider 使用。</p>
<hr />
]]></description><link>https://lcz.me/topic/279/hermes-接入-codex-oauth-串-telegram-與本地-qwen-實戰筆記-chatgpt-plus可調用api給hermes</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Jul 2026 19:55:52 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/279.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 May 2026 11:05:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Sun, 12 Jul 2026 13:45:32 GMT]]></title><description><![CDATA[<p dir="auto">其实这条是死路，oauth看似通了实际上建立的是弱链接。随时有可能codex还会过来抢, 到时候就会有玄学问题。</p>
]]></description><link>https://lcz.me/post/9795</link><guid isPermaLink="true">https://lcz.me/post/9795</guid><dc:creator><![CDATA[TT Mic]]></dc:creator><pubDate>Sun, 12 Jul 2026 13:45:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Sat, 11 Jul 2026 00:07:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chia-an-yang" aria-label="Profile: CHIA-AN-YANG">@<bdi>CHIA-AN-YANG</bdi></a> 不要修改原贴新增。</p>
]]></description><link>https://lcz.me/post/9681</link><guid isPermaLink="true">https://lcz.me/post/9681</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sat, 11 Jul 2026 00:07:49 GMT</pubDate></item><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Fri, 10 Jul 2026 14:31:21 GMT]]></title><description><![CDATA[<p dir="auto">本文新增接gemini pro訂閱額度給herems調用的簡單教學,這樣一來有codex,gemini 輪流調用</p>
]]></description><link>https://lcz.me/post/9655</link><guid isPermaLink="true">https://lcz.me/post/9655</guid><dc:creator><![CDATA[CHIA AN YANG]]></dc:creator><pubDate>Fri, 10 Jul 2026 14:31:21 GMT</pubDate></item><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Sat, 23 May 2026 19:38:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry" aria-label="Profile: terry">@<bdi>terry</bdi></a> 已附上</p>
]]></description><link>https://lcz.me/post/3306</link><guid isPermaLink="true">https://lcz.me/post/3306</guid><dc:creator><![CDATA[CHIA AN YANG]]></dc:creator><pubDate>Sat, 23 May 2026 19:38:19 GMT</pubDate></item><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Sat, 23 May 2026 11:55:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chia-an-yang" aria-label="Profile: CHIA-AN-YANG">@<bdi>CHIA-AN-YANG</bdi></a> 是我感谢你，你的帖子一般写的都很认真，质量很高。这个帖子要补充点图片，你再修饰下。</p>
]]></description><link>https://lcz.me/post/3268</link><guid isPermaLink="true">https://lcz.me/post/3268</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sat, 23 May 2026 11:55:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Sat, 23 May 2026 11:54:26 GMT]]></title><description><![CDATA[<p dir="auto">感謝置頂!!下午折騰了一下成功,成就感很高~特來分享給版主</p>
]]></description><link>https://lcz.me/post/3265</link><guid isPermaLink="true">https://lcz.me/post/3265</guid><dc:creator><![CDATA[CHIA AN YANG]]></dc:creator><pubDate>Sat, 23 May 2026 11:54:26 GMT</pubDate></item><item><title><![CDATA[Reply to Hermes 接入 Codex OAuth、串 Telegram 與本地 Qwen 實戰筆記 (chatgpt plus可調用API給hermes) on Sat, 23 May 2026 11:38:34 GMT]]></title><description><![CDATA[<p dir="auto">这.....不明觉厉，文稿质量很高，只不过配点截图会更好，这样更为真实。对于有需要的人而言，确实是非常好的参考，置顶。</p>
]]></description><link>https://lcz.me/post/3251</link><guid isPermaLink="true">https://lcz.me/post/3251</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sat, 23 May 2026 11:38:34 GMT</pubDate></item></channel></rss>