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 是速度敏感型 agent 循環的最快選擇,而 Gemini 2.5 Pro 提供 100 萬 token 上下文窗口和思考模式。

Gemini 使用場景

Live API 實時語音和影片對話

使用 Gemini 的多模態能力,構建實時處理音頻和影片輸入(同時結合文本)的應用,通過 Hermes Agent 工作流打造能看能聽的交互式 agent。

基於 Google 搜索數據的響應接地

在 Hermes Agent 工作流中啓用 Gemini 的搜索接地功能,為需要最新信息的任務提供事實準確的回答,減少幻覺現象。

多模態文檔處理工作流程

在單次 Hermes Agent 運行中處理包含混合內容類型(PDF、圖像、表格)的文檔,從掃描表格提取數據、總結多媒體報告或對影片內容進行分類。

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。