HERMES + GEMINI

在 Hermes Agent 中使用 Gemini。

Google Gemini 可透過 RunAPI 的 OpenAI 相容端點使用。Hermes Agent 透過 custom:runapi provider 呼叫它 — Gemini 3.5 Flash 適合對速度敏感的 agent 迴圈,3.x Pro 適合多步驟推理,2.5 Pro 適合長上下文的正式環境任務。不需要 Google Cloud 專案或 Vertex AI 憑證 — 只需你已為 chat 設定好的 RUNAPI_API_KEY 和 base_url。

一個 API key · OpenAI 相容 chat 端點 · 支援串流
Use RunAPI to send a chat request to Google Gemini 3.5 Flash through Hermes Agent.

Requirements:
- Use the custom:runapi provider already configured in Hermes Agent
- Call the RunAPI chat completions endpoint at https://runapi.ai/v1/chat/completions
- Set model to "gemini-3.5-flash"
- The RUNAPI_API_KEY environment variable provides authorization
- The response is synchronous — the reply arrives in choices[0].message.content
- For streaming, set stream to true and process server-sent events
curl -X POST https://runapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $RUNAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.5-flash",
    "messages": [
      {"role": "system", "content": "You are a concise technical assistant."},
      {"role": "user", "content": "Explain the difference between gRPC and REST in three sentences."}
    ],
    "temperature": 0.7,
    "max_tokens": 256
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "gemini-3.5-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "gRPC uses HTTP/2 and Protocol Buffers for strongly-typed, multiplexed RPC calls with built-in code generation. REST uses HTTP/1.1 (or 2) with JSON payloads and relies on URL paths and HTTP verbs for resource semantics. gRPC is faster for service-to-service calls; REST is simpler to debug and more widely supported by browsers."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 34,
    "completion_tokens": 71,
    "total_tokens": 105
  }
}
複製 curl 指令進行測試 gemini
運作原理

三個步驟在 Hermes Agent 中使用 Gemini

1

設定 RunAPI

設定 RUNAPI_API_KEY 環境變數。如果你已在 Hermes Agent 中將 RunAPI 新增為 custom:runapi provider,相同的 key 和 base_url 即可用於 Gemini — 只需更改 model ID。不需要 Google Cloud 憑證。

export RUNAPI_API_KEY=runapi_xxx
2

透過 chat completions 呼叫 Gemini

發送 POST 請求到 /v1/chat/completions,將 model 設為 gemini-3.5-flash。傳入包含 system 和 user 角色的 messages 陣列。Hermes Agent 發送與呼叫 GPT 時相同的 OpenAI 相容請求格式 — RunAPI 根據 model 參數路由到 Gemini。

POST /v1/chat/completions
3

讀取回應

回應以 OpenAI chat completion 格式同步返回。助手的回覆在 choices[0].message.content 中,token 使用量在 usage 物件中。若要串流,將 stream 設為 true,Hermes Agent 會自動解析 SSE delta 事件。

choices[0].message.content
參數

Gemini chat completions API 參數

參數 類型 說明
model string 必填。gemini-3.5-flash、gemini-2.5-flash、gemini-2.5-pro、gemini-3-flash-preview、gemini-3-pro-preview 或 gemini-3.1-pro-preview。
messages array 必填。包含 role(system、user、assistant)和 content 欄位的訊息物件陣列。
temperature number 選填。取樣溫度,介於 0 到 2 之間。較低的值產生更確定性的輸出。預設值因模型而異。
max_tokens integer 選填。回應中生成的最大 token 數。
stream boolean 選填。設為 true 時,回應以 server-sent events 串流傳送。每個事件包含帶有部分內容的 delta。
top_p number 選填。Nucleus 取樣閾值,介於 0 到 1 之間。作為 temperature 的替代方案來控制輸出隨機性。

Hermes Agent 上的 Gemini 是什麼?

Google Gemini 透過 RunAPI 的 custom:runapi provider 提供,無需任何 Google Cloud 憑證。Hermes Agent 使用與 GPT 和 Claude 相同的 OpenAI 相容設定呼叫它。Gemini 3.5 Flash 是速度敏感型代理循環的最快選項,而 Gemini 2.5 Pro 提供 100 萬 token 上下文視窗和複雜多步驟推理任務的思考模式。

Gemini 使用情境

使用 Live API 的即時語音與影片聊天

在 Hermes Agent 工作流程中,使用 Gemini 的多模態能力構建能同時處理音訊和影片輸入及文字的即時應用程式,讓互動式代理能夠看見和聆聽。

以 Google 搜尋資料為回應提供依據

在 Gemini 請求上啟用 Google 搜尋依據,獲得基於即時網路資料的回應,適用於需要超出訓練截止日期最新資訊的代理。

低成本代理工具呼叫鏈

在代理需要進行大量連續呼叫的快速低成本工具呼叫循環中,使用 Gemini 3.5 Flash。次 100ms 的首 token 延遲讓代理鏈保持響應性,同時不超出預算。

FAQ

Gemini + Hermes Agent 常見問題

Hermes Agent 通用設定

尚未設定?請從 Hermes Agent 的 RunAPI 設定指南開始。

Hermes Agent 設定指南 →

Gemini 模型目錄

查看所有 Gemini 版本、定價方案和 API 文件。

Gemini models →

立即在 Hermes Agent 中試用 Gemini。

取得免費的 RunAPI key,在你的 custom:runapi provider 中將 model 設為 gemini-3.5-flash,即可開始在 Hermes Agent 中使用 Gemini。