在 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。
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
}
}
三個步驟在 Hermes Agent 中使用 Gemini
設定 RunAPI
設定 RUNAPI_API_KEY 環境變數。如果你已在 Hermes Agent 中將 RunAPI 新增為 custom:runapi provider,相同的 key 和 base_url 即可用於 Gemini — 只需更改 model ID。不需要 Google Cloud 憑證。
export RUNAPI_API_KEY=runapi_xxx
透過 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
讀取回應
回應以 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、圖像、表格)的文檔,從掃描表格提取數據、總結多媒體報告或對影片內容進行分類。
Gemini + Hermes Agent 常見問題
是的。RunAPI 透過其 OpenAI 相容端點提供 Gemini。在 Hermes Agent 中將 RunAPI 設定為 custom:runapi provider,base_url 為 https://runapi.ai/v1,key_env 為 RUNAPI_API_KEY。不需要 Google Cloud 專案、Service Account 或 Vertex AI 設定。
Gemini 3.5 Flash(gemini-3.5-flash)是最新且最快的 — 最適合即時 agent 迴圈和工具呼叫鏈。Gemini 2.5 Pro(gemini-2.5-pro)處理長上下文任務和複雜推理。Gemini 3.x Pro 預覽版本以較高成本提供最新的推理能力。
Gemini 在 RunAPI 上按 token 計費,採用隨用隨付定價。輸入和輸出 token 分別計量。無月費、無最低消費。請查看 RunAPI 定價頁面了解目前的每百萬 token 費率。
可以。所有 RunAPI LLM 共用相同的 custom:runapi provider 和 API key。使用 /model 指令或 hermes model 在 gemini-3.5-flash、gpt-5.5、claude-opus-4.6 或其他任何 RunAPI 模型之間切換,無需更改 provider 設定。
是的。RunAPI 將 OpenAI 相容的 tools 和 tool_choice 參數傳遞給 Gemini。在請求主體中定義 tools,Gemini 會在助手訊息中返回 tool_calls。Hermes Agent 處理方式與處理 GPT 或 Claude 的工具呼叫相同。
立即在 Hermes Agent 中試用 Gemini。
取得免費的 RunAPI key,在你的 custom:runapi provider 中將 model 設為 gemini-3.5-flash,即可開始在 Hermes Agent 中使用 Gemini。