الأكاديمية ← أدلة تطبيقيةتوثيق رسمي · إرشاد عربي

التشغيل عبر Google Gemini

Google Gemini

متوسط7 دقائق قراءةالدرس 254 أسئلة✓ 2026-08-18
قبل أن تقرأ

ما هذه الصفحة، وماذا تحتوي.

المزوّد والنموذج: المزوّد هو الشركة التي تشغّل نموذج الذكاء الاصطناعي، والنموذج هو «العقل» الذي يفكّر لـHermes. Hermes نفسه لا يفكّر؛ هو ينظّم العمل ويستدعي النموذج. لذلك اختيار النموذج يحدّد جودة النتيجة وتكلفتها. ستستعمل هنا hermes model وhermes chat، والقراءة نحو 7 دقائق. انتبه: الأغلى ليس دائمًا الأفضل لمهمتك. جرّب مهمة واحدة على نموذجين وقارن، وضع سقفًا للإنفاق من البداية.

9أقسام
16أمثلة برمجية
3جداول
3أوامر
1,137كلمة من المصدر
الوصف الرسمي في سطر

Use Hermes Agent with Google Gemini — native AI Studio API, API-key setup, tool calling, streaming, and quota guidance

ماذا ستستطيع بعدها

نتائج مأخوذة من هذه الصفحة، لا من قالب.

  • تعرف ما المزوّد والنموذج ولماذا قد تحتاجه.
  • تنفّذ hermes model وhermes chat وتفهم ما يحدث بعدها.
  • تقرأ الجدول وتأخذ منه السطر الذي يخصّك فقط.
  • تضبط GOOGLE_API_KEY في المكان الصحيح.
ما ستقابله من أسماء

كما تظهر تمامًا داخل Hermes.

الأوامر
  • hermes model
  • hermes chat
  • hermes doctor
متغيرات البيئة
  • GOOGLE_API_KEY
  • GEMINI_API_KEY
  • GEMINI_BASE_URL
خريطة الصفحة

انتقل مباشرة إلى ما تحتاجه.

  1. 01Prerequisites
  2. 02Quick Start
  3. 03Configuration
  4. 04Available Models
  5. 05Switching Models Mid-Session
  6. 06Diagnostics
  7. 07Gateway (Messaging Platforms)
  8. 08Troubleshooting
  9. 09Related
الصفحة الرسمية كاملة

بلا اختصار أو حذف.

النص أدناه منقول من المصدر الرسمي بالإنجليزية حتى تبقى الأوامر والأسماء دقيقة كما هي. قبل كل قسم شرح عربي يوضّح ما بداخله.

Hermes Agent supports Google Gemini as a native provider using the Google AI Studio / Gemini API — not the OpenAI-compatible endpoint. This lets Hermes translate its internal OpenAI-shaped message and tool loop into Gemini's native generateContent API while preserving tool calling, streaming, multimodal inputs, and Gemini-specific response metadata.

Prerequisites

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. تضبط GOOGLE_API_KEY، GEMINI_API_KEY خارج المحادثة، في بيئة التشغيل.

  • Google AI Studio API key — create one at aistudio.google.com/apikey ↗
  • Billing-enabled Google Cloud project — recommended for agent use. Gemini's free tier is too small for long-running agent sessions because Hermes may make several model calls per user turn.
  • Hermes installed — no extra Python package is required for the native Gemini provider.

Quick Start

خطوات عملية بالترتيب. نفّذ خطوة وتأكد أنها نجحت قبل الانتقال للتالية. الأوامر هنا: hermes chat، hermes model.

Shell11 سطرًا
# Add your Gemini API key
echo "GOOGLE_API_KEY=..." >> ~/.hermes/.env

# Select Gemini as your provider
hermes model
# → Choose "More providers..." → "Google AI Studio"
# → Hermes checks your key tier and shows Gemini models
# → Select a model

# Start chatting
hermes chat

If you prefer direct config editing, use the native Gemini API base URL:

YAML4 أسطر
model:
  default: gemini-3-flash-preview
  provider: gemini
  base_url: https://generativelanguage.googleapis.com/v1beta

Configuration

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. الأوامر هنا: hermes model. تضبط GOOGLE_API_KEY، GEMINI_BASE_URL خارج المحادثة، في بيئة التشغيل.

After running hermes model, your ~/.hermes/config.yaml will contain:

YAML4 أسطر
model:
  default: gemini-3-flash-preview
  provider: gemini
  base_url: https://generativelanguage.googleapis.com/v1beta

And in ~/.hermes/.env:

Shellسطر واحد
GOOGLE_API_KEY=...

Native Gemini API

The recommended endpoint is:

Textسطر واحد
https://generativelanguage.googleapis.com/v1beta

Hermes detects this endpoint and creates its native Gemini adapter. Internally, Hermes still keeps the agent loop in OpenAI-shaped messages, then translates each request to Gemini's native schema:

  • messages[] → Gemini contents[]
  • system prompts → Gemini systemInstruction
  • tool schemas → Gemini functionDeclarations
  • tool results → Gemini functionResponse parts
  • streaming responses → OpenAI-shaped stream chunks for the Hermes loop

Prefer the Native Endpoint

Google also exposes an OpenAI-compatible endpoint:

Textسطر واحد
https://generativelanguage.googleapis.com/v1beta/openai/

For Hermes agent sessions, prefer the native Gemini endpoint above. Hermes includes a native Gemini adapter so it can map multi-turn tool use, tool-call results, streaming, multimodal inputs, and Gemini response metadata directly onto Gemini's generateContent API. The OpenAI-compatible endpoint is still useful when you specifically need OpenAI API compatibility.

If you previously set GEMINI_BASE_URL to the /openai URL, remove it or change it:

Shellسطر واحد
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta

Available Models

جدول مرجعي. لا تقرأه كله، ابحث عن السطر الذي يخصّك فقط. الأوامر هنا: hermes model.

The hermes model picker shows Gemini models maintained in Hermes' provider registry. Common choices include:

ModelIDNotes
Gemini 3.1 Pro Previewgemini-3.1-pro-previewMost capable preview model when available
Gemini 3 Pro Previewgemini-3-pro-previewStrong reasoning and coding model
Gemini 3 Flash Previewgemini-3-flash-previewRecommended default balance of speed and capability
Gemini 3.1 Flash Lite Previewgemini-3.1-flash-lite-previewFastest / lowest-cost option when available

Model availability changes over time. If a model disappears or is not enabled for your key, run hermes model again and pick one from the current list.

Latest Aliases

Google publishes moving aliases for the Pro and Flash Gemini families. gemini-pro-latest and gemini-flash-latest are useful when you want Google to advance the model automatically without changing your Hermes config.

AliasCurrently tracksNotes
gemini-pro-latestLatest Gemini Pro modelBest when you want Google's current Pro default
gemini-flash-latestLatest Gemini Flash modelBest when you want Google's current Flash default
YAML4 أسطر
model:
  default: gemini-pro-latest
  provider: gemini
  base_url: https://generativelanguage.googleapis.com/v1beta

If you need strict reproducibility, prefer explicit model IDs such as gemini-3.1-pro-preview or gemini-3-flash-preview.

Gemma via the Gemini API

Google also exposes Gemma models through the Gemini API. Hermes recognizes these as Google models, but hides very low-throughput Gemma entries from the default model picker so new users do not accidentally select an evaluation-tier model for a long-running agent session.

Useful evaluation IDs include:

ModelIDNotes
Gemma 4 31B ITgemma-4-31b-itLarger Gemma model; useful for compatibility and quality evaluation
Gemma 4 26B A4B ITgemma-4-26b-a4b-itSmaller active-parameter variant when available

These models are best treated as evaluation options on Gemini API keys. Google's Gemma API pricing is free-tier-only and the usage caps are low compared with production Gemini models, so sustained Hermes agent use should normally move to a paid Gemini model, a self-hosted deployment, or another provider with appropriate quota.

To use a Gemma model that is hidden from the picker, set it directly:

YAML4 أسطر
model:
  default: gemma-4-31b-it
  provider: gemini
  base_url: https://generativelanguage.googleapis.com/v1beta

Switching Models Mid-Session

أوامر تكتبها في الطرفية. افهم ما يفعله الأمر قبل نسخه. الأوامر هنا: hermes model.

Use the /model command during a conversation:

Text6 أسطر
/model gemini-3-flash-preview
/model gemini-flash-latest
/model gemini-3-pro-preview
/model gemini-pro-latest
/model gemma-4-31b-it
/model gemini-3.1-flash-lite-preview

If you have not configured Gemini yet, exit the session and run hermes model first. /model switches among already-configured providers and models; it does not collect new API keys.

Diagnostics

إعدادات تضبطها مرة وتنساها. غيّر واحدًا في كل مرة حتى تعرف أثر كل تغيير. الأوامر هنا: hermes doctor. تضبط GOOGLE_API_KEY، GEMINI_API_KEY خارج المحادثة، في بيئة التشغيل.

Shellسطر واحد
hermes doctor

The doctor checks:

  • Whether GOOGLE_API_KEY or GEMINI_API_KEY is available
  • Whether configured provider credentials can be resolved

Gateway (Messaging Platforms)

شرح للفكرة نفسها. اقرأه ببطء، فبقية الأقسام تبني عليه. تذكير: المزوّد هو الشركة التي تشغّل نموذج الذكاء الاصطناعي، والنموذج هو «العقل» الذي يفكّر لـHermes.

Gemini works with all Hermes gateway platforms (Telegram, Discord, Slack, WhatsApp, LINE, Feishu, etc.). Configure Gemini as your provider, then start the gateway normally:

Shellسطران
hermes gateway setup
hermes gateway start

The gateway reads config.yaml and uses the same Gemini provider configuration.

Troubleshooting

قسم لحل المشكلات. ابحث فيه عن العطل الذي يشبه حالتك بدل قراءته كاملًا. الأوامر هنا: hermes model.

"Gemini native client requires an API key"

Hermes could not find a usable API key. Add one of these to ~/.hermes/.env:

Shell3 أسطر
GOOGLE_API_KEY=...
# or
GEMINI_API_KEY=...

Then run hermes model again.

"This Google API key is on the free tier"

Hermes probes Gemini API keys during setup. Free-tier quotas can be exhausted after a handful of agent turns because tool use, retries, compression, and auxiliary tasks may require multiple model calls.

Enable billing on the Google Cloud project attached to your key, regenerate the key if needed, then run:

Shellسطر واحد
hermes model

"404 model not found"

The selected model is not available for your account, region, or key. Run hermes model again and pick another Gemini model from the current list.

Gemma model is not shown in hermes model

Hermes may hide low-throughput Gemma models from the picker by default. If you intentionally want to evaluate one, set the model ID directly in ~/.hermes/config.yaml.

"429 quota exceeded" on Gemma

Gemma models exposed through the Gemini API are useful for evaluation, but their Gemini API free-tier caps are low. Use them for compatibility testing, then switch to a paid Gemini model or another provider for sustained agent sessions.

OpenAI-compatible endpoint is configured

Check ~/.hermes/.env for:

Shellسطر واحد
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/

Change it to the native endpoint or remove the override:

Shellسطر واحد
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta

Tool calling fails with schema errors

Upgrade Hermes and rerun hermes model. The native Gemini adapter sanitizes tool schemas for Gemini's stricter function-declaration format; older builds or custom endpoints may not.

اختبار الفهم

4 أسئلة إجاباتها كلها في هذه الصفحة.

كل خيار اسم حقيقي من توثيق Hermes. حتى الخيارات الخاطئة حقيقية، لكنها من صفحات أخرى.

1. في جدول هذا الدرس، ما «ID» المقابل لـ«Gemini 3.1 Pro Preview»؟
2. أي متغير بيئة من التالي يظهر فعليًا في هذا الدرس؟
3. أي عنوان من التالي لا يظهر في هذا الدرس؟
4. أي مفتاح إعداد يظهر في أمثلة هذا الدرس؟