Hermes Agent
How to use Gemma 4 with Hermes Agent
Updated 5 December 2026
Use Ollama, llama.cpp or LM Studio to run Gemma 4 E4B or 12B locally with Hermes Agent. For hosted Gemma 4, the Gemini API and OpenRouter routes below use 26B A4B or 31B. With a local runtime, check how much context it gives the session and whether Hermes can execute a tool call.
Sources read on 4 December 2026 include the Hermes Agent 0.23.6 documentation and tagged source, plus Google’s Gemma 4 model card. The setup details use Ollama 0.40.21, llama.cpp 1.1.1, LM Studio 0.4.29 build 2, the Gemini API v1beta documentation for Gemma and OpenRouter’s live API v1 model catalogue.
Choose a Gemma 4 model
Gemma 4 is Google DeepMind’s family of open-weight models. Use an instruction-tuned variant with Hermes. Gemma generates text and can return a structured request to call a function. Hermes executes the tool and passes the result back to the model.
| Gemma 4 model | Model type | Advertised context | Ollama tag |
|---|---|---|---|
| E2B | Dense | 128K tokens | gemma4:e2b |
| E4B | Dense | 128K tokens | gemma4:e4b |
| 12B Unified | Dense | 256K tokens | gemma4:12b |
| 26B A4B | Mixture of experts, 3.8B active parameters | 256K tokens | gemma4:26b |
| 31B Dense | Dense | 256K tokens | gemma4:31b |
There are five sizes. The four-size list dates to the April launch. The table follows Google’s current model card, which includes the 12B model added in June. Google’s checkpoint configs give the exact limits for E4B at 131,072 tokens and 12B at 262,144 tokens.
If you are starting from scratch, install Hermes Agent before configuring one of the model providers below.
Allow at least 64,000 tokens per session
All five model limits clear Hermes Agent 0.23.6’s 64,000-token minimum. The context window is the total token budget for the prompt, tool definitions, conversation history and generated response. A server can allocate less than the model supports, so check the window it gives each session.
The tagged startup check generally rejects a known window below 64,000. Its LM Studio exception allows startup with an explicitly configured positive integer model.context_length below that floor. The Ollama tool-use check can stop a turn when the detected or configured runtime window is too small.
Hermes’s last-resort Gemma 4 family estimate is 256,000 tokens. It can overstate E2B and E4B. Use the runtime’s actual window when checking the setup. A model.context_length pin tells Hermes what window to use for its own context calculations. Configure the actual allocation in the runtime too.
Run Gemma 4 in Ollama
- Install Ollama using Google’s setup instructions. Check the installation with
ollama --version. - Set a context window of at least 64,000 tokens in Ollama.
- In the Ollama app, use the context slider in settings.
- If you manage Ollama from a macOS or Linux shell, stop the running server and restart it with this setting.
OLLAMA_CONTEXT_LENGTH=64000 ollama serve - If Linux runs Ollama as a systemd service, use the Ollama service instructions to set
OLLAMA_CONTEXT_LENGTH=64000on the service and restart it.
- Run
ollama run gemma4:12b,ollama run gemma4:e4borollama run gemma4:31band send a short prompt. While the model is loaded, runollama psin another terminal and check the CONTEXT column. If it shows fewer than 64,000 tokens, increase the context in Ollama, reload the model and check again. - Run
hermes modeland choose Custom endpoint (enter URL manually). Enterhttp://localhost:11434/v1, leave the key field blank and choose Chat Completions. Select the exact Ollama tag or type it when prompted. At the context prompt, enter the value Ollama reported in the CONTEXT column. Accept the default display name.
For a fresh Hermes configuration, you can use this model block in ~/.hermes/config.yaml. If you’re switching from another endpoint, use the wizard above. For 12B or E4B, set default to the Ollama tag you selected.
model:
default: "gemma4:31b"
provider: "custom"
base_url: "http://localhost:11434/v1"For the default context, follow the versioned Ollama docs. The Hermes Ollama guide gives 2,048, while Ollama 0.40.21 sets the default from available GPU memory and can start below the Hermes minimum. A download size measures disk use. The loaded model needs runtime memory, and increasing the context increases that requirement.
The Ollama server controls the actual context window. If you use YAML, set context_length under model to the value shown in the CONTEXT column of ollama ps. For example, if Ollama reports 64,000 tokens, use context_length: 64000. For more server setup options, see the Hermes Agent Ollama guide.
Serve Gemma 4 with standalone llama.cpp
- Download and extract the archive for your operating system from the build linked in the llama.cpp 1.1.1 release. On macOS or Linux, run the command below from the folder containing the extracted executable. On Windows, run
llama-server.exefrom that folder in Command Prompt with the same options. For E4B or 12B, replace the repository after-hfwithggml-org/gemma-4-E4B-it-GGUForggml-org/gemma-4-12B-it-GGUF../llama-server -hf ggml-org/gemma-4-E2B-it-GGUF -c 64000 -np 1 --port 8080 - The command requests a 64,000-token window for a single session slot. Multiple slots can reduce the context available to each session. Open
http://localhost:8080/propsand confirm thatdefault_generation_settings.n_ctxis at least 64,000. - Run
hermes model, choose Custom endpoint (enter URL manually) and enterhttp://localhost:8080/v1. Leave the key field blank for the local example. Choose Chat Completions, then confirm the detected model or enter the served model name. Enter the context you verified on the server and accept the default display name.
Hermes’s provider guide asks you to add --jinja for tool calling. The upstream llama.cpp 1.1.1 options are authoritative for this standalone release, where Jinja is enabled by default and the code can recognise a Gemma 4 chat template. At http://localhost:8080/props, check the values of supports_tools and supports_tool_calls under chat_template_caps. Then test an actual tool call in Hermes. The llama.cpp guide covers the general integration.
Load Gemma 4 in LM Studio
- Install LM Studio using Google’s LM Studio instructions. Open the app once before running
lms. Download 12B withlms get google/gemma-4-12b, or search forgoogle/gemma-4-e4bin the app for E4B. - Run
lms lsto find the downloaded model. Replacemodel-namewith that model’s key in the load command. To estimate memory before loading, uselms load model-name --context-length 64000 --estimate-only.lms load model-name --context-length 64000 - Run
lms server startor select Start Server in the app’s Developer tab. Check the port withlms server status. - Run
hermes modeland choose LM Studio. At theLM_API_KEYprompt, enter the server token if authentication is enabled. For a first-time setup with authentication disabled, press Enter. At the base URL prompt, usehttp://127.0.0.1:1234/v1if the server uses port 1234, or replace 1234 with the port you confirmed. Then select your Gemma 4 model.
Hermes preserves the context of a model that is already loaded. If you loaded it with a smaller window, set Context Length in the app and reload the model. In the default explicit loading mode, an unloaded model uses LM Studio’s setting unless you configured a window in Hermes. When LM Studio reports the loaded context, Hermes uses that value for its context budget, capped at model.context_length if you set it.
Use hosted Gemma 4 through the Gemini API
Google hosts gemma-4-31b-it and gemma-4-26b-a4b-it on this API. To use E4B or 12B, pick one of the local routes above. Hermes hides the two hosted IDs from its Gemini picker because the input-token quota is low for agent traffic. Set the ID directly.
- Create an API key in Google AI Studio. In
~/.hermes/.env, setGOOGLE_API_KEYto the new key. If that setting already exists in the file, replace its value. - Replace the existing
modelblock in~/.hermes/config.yamlwith the block below. Keep a singlemodelblock. For 26B A4B, setdefaulttogemma-4-26b-a4b-it.model: default: gemma-4-31b-it provider: gemini base_url: https://generativelanguage.googleapis.com/v1beta - Use a test environment whose account name and directory paths contain no sensitive, confidential or personal information. With the local terminal backend, Hermes can send the paths to your home directory, working directory and Hermes profile with its first request. Check that the profile’s saved memory and instructions contain only sample data. Start
hermesfrom an empty directory outside your projects and check the model in the welcome banner.
Use this route for evaluation with sample data. Google’s terms for unpaid services say to keep sensitive, confidential and personal information out of requests. Hermes can send file contents and tool results during the session.
Google’s Gemma 4 pricing table puts model input and output on the free tier and marks the paid tier unavailable. Hermes’s normal reasoning setting also leaves Gemma’s thinking configuration unset in 0.23.6, even though Google documents a direct API control for it.
Use paid Gemma 4 through OpenRouter
OpenRouter’s paid 31B and 26B A4B listings both reported 262,144 tokens of context and included tools in the catalogue’s supported parameters. Use this route if you want paid hosted inference for one of those sizes.
- Make sure your OpenRouter account has enough credits and create an API key on the OpenRouter keys page.
- Run
hermes model, choose OpenRouter and enter the key or keep your existingOPENROUTER_API_KEY. Choose Enter custom model name and typegoogle/gemma-4-31b-itorgoogle/gemma-4-26b-a4b-it. The wizard saves the choice with provideropenrouterand base URLhttps://openrouter.ai/api/v1. - Start
hermesand check the model in the welcome banner.
See the Hermes Agent OpenRouter guide for provider setup and tool-calling diagnostics.
Check a reply and an actual tool call
- Keep Hermes warning notifications enabled throughout the test. Open
hermes, check the selected model in the welcome banner and send a short greeting. - Enter
/verbose allto show tool activity. Ask Hermes to runread_fileon the full path to a text file containing only sample data. Confirm that the tool ran and the reply matches the file. If either the greeting or the tool test shows a Model fallback notice, fix the reported error and repeat the test. - If the model prints a tool call as text, check that the chosen tool is listed under
/toolsand that the runtime returns structured calls with the model’s chat template. If Hermes reports a small context window, check the runtime’s allocation and reload the model after changing it.
For a refused local connection, check that the model server is running and that Hermes can reach the address you entered. If Hermes runs in WSL2 and the model server runs on Windows, mirrored networking lets Hermes reach the server at localhost on supported Windows versions. See the Hermes instructions for mirrored networking. If you use NAT networking, find the Windows host’s IP address from inside WSL2 and use it in the Hermes base URL in place of localhost. Set the Windows model server to listen on an address WSL2 can reach. If you need a firewall rule, allow only inbound traffic from WSL2 on the model server’s port. Keep the server off the public internet.
The Hermes Ollama guide’s comment about only 31B having reliable tool calling applies to its table, where 31B is the only Gemma 4 entry. Google demonstrates native function calling even on E2B. That establishes model support. Test E4B or 12B with your own tools and runtime before relying on it for a sequence of actions.
Gemma 4 on ReadyHermes
ReadyHermes runs your Hermes Agent on its servers. We have not tested Gemma 4 through any provider on ReadyHermes. The local setup above is for an installation you run yourself, and ReadyHermes does not provide a screen for editing config.yaml.
The Model key panel is available during the trial and on paid plans. For a supported hosted provider, choose Your own API key, pick the provider, paste the key, select or type the model ID and press Switch to my key. The provider list includes Google Gemini and OpenRouter. ReadyHermes sends a small test message before restarting the assistant, which takes about a minute.
For a custom hosted model, Other endpoint accepts an OpenAI-compatible API at a public HTTPS hostname on port 443. The API must accept the key as a bearer token without requiring extra custom headers. A path such as /v1 is allowed. Leave out query strings and credentials in the URL. Localhost, private addresses and bare IP addresses are refused. ReadyHermes tests /chat/completions under the base URL.
Questions
Can you run Gemma 4 E4B or 12B with Hermes Agent?
Yes. For local inference, use Ollama, standalone llama.cpp or LM Studio. In Ollama, the exact tags are gemma4:e4b and gemma4:12b. Google lists 128K tokens for E4B and 256K for 12B, and you should check the window your runtime actually allocates.
How much context does Hermes Agent need for Gemma 4?
Hermes Agent 0.23.6 generally rejects a known context window below 64,000 tokens. The relevant figure is the window the runtime allocates per session. LM Studio has a startup exception for an explicitly configured positive integer model.context_length.
Does Gemma 4 support tool calling in Hermes Agent?
Gemma 4 supports native function calling. Hermes needs the endpoint to return a structured call so it can run the tool. Keep Hermes warning notifications enabled. Use /verbose all to show tool activity, then ask Hermes to run read_file on a sample file. Confirm that the tool ran, the reply matches the file and neither the greeting nor the tool test showed a Model fallback notice.
Why is Gemma 4 missing from the Gemini model picker?
Hermes Agent 0.23.6 hides the two hosted Gemma 4 IDs because their input-token quota is low for agent traffic. Replace the model block in ~/.hermes/config.yaml. Set the provider to gemini, use the native Gemini API base URL and set the default to gemma-4-31b-it or gemma-4-26b-a4b-it.
Has Gemma 4 been tested on ReadyHermes?
We have not tested Gemma 4 through any provider on ReadyHermes. The Model key panel lists Google Gemini and OpenRouter. Other endpoint accepts an OpenAI-compatible API at a public HTTPS hostname on port 443. The API must accept the key as a bearer token without requiring extra custom headers.