· reAPI Team
Running NousResearch Hermes Agent on Custom LLM Gateways
Configure NousResearch Hermes Agent with custom LLM gateways in config.yaml, enforce the 64K context floor, and run hermes gateway on port 8642.

Developers deploying NousResearch/hermes-agent (MIT-licensed, at 267.9k GitHub stars and 81,277 commits on December 3, 2026) routinely mix up two separate OpenAI-compatible HTTP surfaces inside the runtime.[1] Upstream, NousResearch Hermes Agent acts as an OpenAI API client defined in ~/.hermes/config.yaml, sending multi-turn tool calls to any inference provider that clears a 64,000-token minimum context floor, such as https://api.reapi.ai/v1 serving discounted claude-opus-5-5:claude-0.5, gpt-6.2-sol:gpt-0.1, or deepseek-v4.1-flash.[2][5][8][9][10] Downstream, enabling ~/.hermes/.env and launching hermes gateway turns Hermes Agent itself into an OpenAI-compatible HTTP server on http://127.0.0.1:8642/v1 for Open WebUI, LobeChat, LibreChat, NextChat, and Python OpenAI SDK clients.[3][6]
Mixing those boundaries causes most first-day failures: pointing config.yaml at port 8642 triggers a loopback cycle, pasting a provider key into API_SERVER_KEY breaks auth with 401 Unauthorized, and sending hyphenated page slugs instead of dotted wire IDs fails with Model Not Found.[3][5][9] Because one AIAgent class in run_agent.py drives the CLI, desktop app, over 20 messaging platforms, cron jobs, and the HTTP API server, separating upstream inference from downstream serving stabilizes every surface at once.[3][7]

Separating Upstream Providers From Downstream API Serving
Before editing local files, separate both OpenAI-compatible interfaces by direction, configuration path, credential, base URL, and model string.[2][3][5]
| Integration layer | Traffic direction | Config file | Auth credential | Base URL | Model field sent |
|---|---|---|---|---|---|
| Upstream LLM gateway[5] | Runtime to inference provider | ~/.hermes/config.yaml[5] | providers.<name>.key_env or api_key[5] | https://api.reapi.ai/v1[8] | claude-opus-5-5:claude-0.5, gpt-6.2-sol:gpt-0.1, deepseek-v4.1-flash[8][9][10] |
| Downstream API server[3] | Frontend or SDK to hermes gateway | ~/.hermes/.env[3] | API_SERVER_KEY bearer token[3] | http://127.0.0.1:8642/v1[3] | hermes-agent or local profile ID from /v1/models[3][6] |
Installation tooling has evolved rapidly since launch on February 25, 2026.[7] Third-party mirrors still cite Python 3.11 and experimental Windows support, whereas the official repository moved its first-party runtime to Python 3.14 on September 7, 2026 (with Node 26 across pnpm workspaces) and ships macOS/Windows desktop installers alongside shell installers for Linux, macOS, WSL2, native PowerShell (iex (irm https://hermes-agent.nousresearch.com/install.ps1)), and aarch64 Android via Termux.[1][2]
# Linux, macOS, or WSL2 (CLI-only without Hermes Desktop)
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
source ~/.zshrcOn first launch, hermes setup detects existing OpenClaw, Claude Code, Codex CLI, or Cursor installs and offers migration via agent-importers.[2] For model routing, hermes setup --portal configures Nous Portal OAuth (over 300 models plus hosted web search, image generation, TTS, and cloud browser via the Tool Gateway), while Use my own API key or a subscription opens hermes model and Blank Slate writes explicit platform_toolsets.cli and agent.disabled_toolsets blocks that enable only File Operations and Terminal tools.[2]
Unlike routing an IDE-focused CLI over Anthropic Messages (covered in connecting Claude Code to a third-party API gateway) or offloading orchestration into an AWS IAM boundary (see when Claude Managed Agents on Bedrock beat custom loops), Hermes Agent keeps USER.md, MEMORY.md, immutable SOUL.md, and self-written ~/.hermes/skills/ on your host, executes up to 8 parallel tool calls through a ThreadPoolExecutor, and outsources only model inference.[7]
Configuring Hermes Agent Upstream Gateways in config.yaml
Beyond more than 30 built-in providers (OpenRouter, Anthropic, Fireworks AI, DeepSeek, AWS Bedrock, Azure Foundry, and local vLLM/SGLang/Ollama servers), Hermes Agent supports any OpenAI-compatible /v1 API inside ~/.hermes/config.yaml without plugins or code edits.[2][5] Create a dedicated key under reAPI API Keys, export REAPI_API_KEY in your shell profile, and bind it through key_env so raw secrets stay out of YAML files.[5][8]
model:
default: gpt-6.2-sol:gpt-0.1
provider: reapi
providers:
reapi:
base_url: https://api.reapi.ai/v1
key_env: REAPI_API_KEY
type: openai
default_model: gpt-6.2-sol:gpt-0.1
models:
- claude-opus-5-5:claude-0.5
- claude-opus-5-5
- gpt-6.2-sol:gpt-0.1
- gpt-6.2-sol:gpt-0.4
- gpt-6.2-sol
- deepseek-v4.1-flashFor headless systemd hosts where inline credentials are required, substitute api_key: sk-your-reapi-key strictly inside providers.reapi; putting api_key at top level leaves the provider unauthenticated and returns 401 Unauthorized.[5]
The Context Window Floor and Model Picker Rules
Every upstream model connected to Hermes Agent must provide at least 64,000 tokens of context.[2] Smaller windows fail startup validation because multi-step tool execution, injected skills, and persistent memory quickly overflow short prompts; local model servers must pass explicit flags (--ctx-size 65536 for llama.cpp or -c 65536 for Ollama).[2] All three reAPI routes exceed that 64,000-token minimum cleanly: DeepSeek V4.1 Flash provides a 1M-token window with 384K documented max output and default thinking enabled across three effort levels, while GPT-6.2 Sol keeps standard token rates up to 272,000 input tokens per call.[9][10]
The models: array directly controls interactive switching. Omitting models: reduces /model to one button for default_model, whereas listing more than 8 entries enables 8-per-page Prev/Next pagination inside Telegram, Discord, Slack, and WhatsApp inline keyboards.[5] Running /model claude-opus-5-5:claude-0.5 changes only the current session, while /model deepseek-v4.1-flash --global persists back to config.yaml; manual YAML edits require restarting hermes or running hermes gateway restart.[5]
Mapping Wire Model IDs and Environment Credentials
Watch the naming split between documentation URLs and live wire identifiers. On reAPI as of December 3, 2026, model pages use hyphenated slugs (/models/gpt-6-2-sol and /models/deepseek-v4-1-flash), whereas POST https://api.reapi.ai/v1/chat/completions requires dotted wire IDs (gpt-6.2-sol, gpt-6.2-sol:gpt-0.1, gpt-6.2-sol:gpt-0.4, and deepseek-v4.1-flash).[9][10] Meanwhile, Claude Opus 5.5 uses hyphenated wire IDs (claude-opus-5-5 and claude-opus-5-5:claude-0.5).[8] Sending gpt-6-2-sol:gpt-0.1 instead of gpt-6.2-sol:gpt-0.1 yields Model Not Found even with a valid key.[5][9]
Because Claude Opus 5.5 on reAPI accepts synchronous OpenAI Chat Completions at POST https://api.reapi.ai/v1/chat/completions (Authorization: Bearer, preserving Anthropic tool and thinking blocks in compatible JSON) alongside its native Anthropic Messages route (POST https://api.reapi.ai/v1/messages), one type: openai block consolidates Anthropic, OpenAI, and DeepSeek models under one balance and /model menu.[5][8][9][10]
Live Token Economics Across Discounted reAPI Routes
Multi-step loops replay MEMORY.md, loaded skills, and prior tool results on every turn, making input volume and prompt-cache reads the primary cost driver for Hermes Agent.[7] One community security audit shared on X logged 1.42M tokens in 5 minutes and 4 seconds ($4.63 on Grok 4.5) during a single task, showing how rapidly autonomous chains accumulate tokens.[7]
Nous Portal offers bundled convenience ($20/month Plus with $22 credits, $100/month Super with $110 credits, $200/month Ultra with $220 credits, and optional Nous Portal Cloud instances starting around $0.32/day for 1GB RAM and 2 vCPUs).[7] Teams already self-hosting on a laptop or VPS can instead route raw token spend through live December 3, 2026 reAPI group IDs (quoted between 10:05 and 10:06 UTC, refreshed every 300 seconds, with 1 credit equal to $0.001 and settled from exact usage without whole-credit rounding).[8][9][10]
| Wire model ID | Group | Input / 1M | Output / 1M | Cache read / 1M | Cache write / 1M | Sample 3.2M-token session |
|---|---|---|---|---|---|---|
claude-opus-5-5 | claude (default) | $2.80 | $14.00 | $0.14 | $3.50 | $6.23[8] |
claude-opus-5-5:claude-0.5 | claude-0.5 | $2.00 | $10.00 | $0.10 | $2.50 | $4.45[8] |
gpt-6.2-sol | gpt (default) | $1.50 | $7.50 | $0.075 | $1.875 | $3.34[9] |
gpt-6.2-sol:gpt-0.4 | gpt-0.4 | $0.80 | $4.00 | $0.04 | $1.00 | $1.78[9] |
gpt-6.2-sol:gpt-0.1 | gpt-0.1 | $0.20 | $1.00 | $0.01 | $0.25 | $0.45[9] |
deepseek-v4.1-flash | deepseek (default) | $0.18 | $0.72 | $0.0036 | $0.18 | $0.33[10] |
The sample column totals a concrete 3.2M-token autonomous workflow: 500,000 uncached input tokens, 500,000 cache-write tokens, 2,000,000 cache-read tokens, and 200,000 output tokens, keeping each request under 272,000 input tokens.[8][9][10] Default claude-opus-5-5 sits 30% below Anthropic's published $4.00 input and $20.00 output list rates (verified October 9, 2026), while claude-opus-5-5:claude-0.5 halves standard base pricing to $2.00/$10.00 and trims the 3.2M-token session from $6.23 to $4.45.[8]
Shifting routine cron digests and repository scanning onto budget routes multiplies savings: the same 3.2M-token run drops to $0.445 ($0.45) on gpt-6.2-sol:gpt-0.1 and $0.3312 ($0.33) on deepseek-v4.1-flash, where 2,000,000 cached reads cost $0.0072.[9][10] Monitor one cliff on GPT-6.2 Sol: once any single prompt crosses 272,000 input tokens, long-context rates activate across every group (gpt-0.1 doubles input to $0.40, cache read to $0.02, and cache write to $0.50, while output increases 50% to $1.50; default gpt climbs to $3.00 input and $11.25 output).[9] DeepSeek V4.1 Flash keeps flat token rates across its entire 1M-token window, protecting unattended log audits from sudden tier jumps.[10]
Exposing Hermes Agent Downstream With hermes gateway
Follow Nous Research's sequencing rule: confirm one normal CLI conversation succeeds before adding messaging adapters, cron triggers, or the HTTP API server.[2] Once upstream inference works cleanly, enable the downstream server in ~/.hermes/.env:[3][6]
API_SERVER_ENABLED=true
API_SERVER_HOST=127.0.0.1
API_SERVER_PORT=8642
API_SERVER_KEY=replace-with-random-local-secret
# Uncomment only if browser JavaScript calls the gateway directly
# API_SERVER_CORS_ORIGINS=http://localhost:3000Non-loopback API_SERVER_HOST bindings enforce API_SERVER_KEY authentication automatically, and setting a key even on 127.0.0.1 blocks local processes from invoking shell tools unauthenticated; optional API_SERVER_CORS_ORIGINS allowlists cache preflight responses for 10 minutes.[3][6] Run hermes gateway, verify [API Server] API server listening on http://127.0.0.1:8642, and connect Open WebUI, LobeChat, LibreChat, or the OpenAI Python SDK to http://127.0.0.1:8642/v1:[3][6]
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:8642/v1",
api_key="replace-with-random-local-secret",
)
resp = client.chat.completions.create(
model="hermes-agent",
messages=[{"role": "user", "content": "Check git status and summarize pending changes."}],
extra_headers={"Idempotency-Key": "repo-audit-2026-12-03-01"},
)
print(resp.choices[0].message.content)Downstream clients pass "hermes-agent" (or a profile name from GET /v1/models), never your upstream reAPI model string.[3][6] Port 8642 exposes four families: stateless POST /v1/chat/completions, SQLite-backed POST /v1/responses (chaining turns via previous_response_id or named conversation state), asynchronous /v1/runs (POST /v1/runs, GET /v1/runs/{run_id}, SSE progress on GET /v1/runs/{run_id}/events, and POST /v1/runs/{run_id}/stop), plus discovery and health checks (GET /v1/models, GET /api/model/options, GET /v1/capabilities, GET /health, and GET /health/detailed).[3][6]
Idempotency Keys, Streaming Conflicts, and Session Lifecycles
May 16, 2026 third-party guides still depict Idempotency-Key as a 5-minute response cache.[6] The November 17, 2026 official API Server specification (api-server.md, 953 lines in NousResearch/hermes-agent) clarifies that a gateway running a session authority (Canonical mode) treats each key as a durable admission identity scoped to the API profile and API_SERVER_KEY; the 5-minute in-memory cache applies only to Legacy mode (without streaming deduplication), while /v1/runs uses a separate 24-hour ledger.[3][4]
Reusing a key in Canonical mode with modified identity fields or a different session triggers admission_conflict and executes nothing.[3][4] Responses and non-streaming Chat Completions return HTTP 409, whereas streaming Chat Completions has already sent HTTP 200 headers and delivers the refusal inside the final SSE chunk (finish_reason: "error", error.message: "admission_conflict") right before data: [DONE].[3][4] Client wrappers inspecting only HTTP status codes on stream: true will miss that refusal completely.[3][4]
Four contract details govern reliable retries against hermes gateway:[3][4]
- Identity fields differ by route:
/v1/responseshashesinput,instructions,previous_response_id,conversation,conversation_history,model,provider,model_options,tools, andtruncation, whereas/v1/chat/completionsexcludestoolsandtool_choice(replaying the original answer when only tool definitions change), and both allow switching between JSON andstream: true.[3][4] - Treat
409 unknown_executionon/v1/responsesas a side-effect warning, because the store recorded the claim (for example from an older release) without an answer, so resending under a new key risks running shell mutations twice.[3][4] - Separate wrap-ups from cancellations: interrupted turns return
finish_reason: "cancelled"and failures return"error"(never"stop"), while exhaustingagent.max_turnsreturns usable summary text withfinish_reason: "length"andhermes.error_code: "iteration_budget_exhausted"on Chat Completions (orstatus: "incomplete"on Responses).[3][4] - Account for deletion tombstones:
DELETE /api/sessions/{id}retains tombstones for 7 days before pruning, permanently retires explicitX-Hermes-Session-Idvalues (returningnot_foundto fresh calls), and in/v1/responsesdepends on a bounded store retaining the 1,000 most recently settled identities per profile by default (10 per stored-response slot; pending or running entries never drop).[3][4]
Tool Progress Streams, Prompt Layering, and Multimodal Payloads
Streaming from hermes gateway emits custom hermes.tool.progress events alongside chat.completion.chunk frames so frontends like Open WebUI can display active tool badges without streaming bulky tool output or polluting saved history; standard OpenAI clients simply ignore unknown event types.[6] On /v1/responses, SSE emits response.created, response.output_text.delta, response.output_item.added, response.output_item.done, and response.completed with structured function_call and function_call_output items.[6] Any system prompt or Responses instructions passed by a frontend appends onto the core system prompt of Hermes Agent without disabling local tools, memory, or skills.[6]
Watch one cross-boundary mismatch on vision inputs. Downstream POST /v1/chat/completions accepts both remote http(s) image URLs and inline data:image/... base64 URIs while keeping structured image arrays separate from gateway slash commands.[3][6] Upstream, reAPI rejects base64 and data: URIs platform-wide in favor of public HTTP(S) URLs.[8][9][10] When routing Open WebUI image turns through reAPI, reference hosted HTTP(S) URLs or upload pasted screenshots before forwarding them upstream.[3][9][10]
Verification Sequence and Common Misconfigurations
Verify bottom-up so upstream credential errors never look like local gateway bugs. First, test https://api.reapi.ai/v1/chat/completions directly outside Hermes:[9]
curl -sS https://api.reapi.ai/v1/chat/completions \
-H "Authorization: Bearer $REAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol:gpt-0.1",
"messages": [{"role": "user", "content": "Reply with OK only."}]
}'Second, run hermes doctor to confirm ~/.hermes/config.yaml loaded the right active provider and default model, then complete one CLI turn via hermes.[2][5] Third, launch hermes gateway, check curl http://127.0.0.1:8642/health ({"status": "ok"}, or GET /health/detailed for session metrics), query GET /v1/models, and send one authenticated test turn to http://127.0.0.1:8642/v1/chat/completions.[3][6]
| Failure symptom | Layer affected | Root cause | Resolution |
|---|---|---|---|
| Startup rejects configured model[2] | Upstream (config.yaml) | Context window below 64,000 tokens[2] | Use a 64K+ hosted model or set --ctx-size 65536 / -c 65536 locally[2] |
401 Unauthorized on first turn[5] | Upstream (config.yaml) | api_key at YAML root instead of providers.<name>, or key_env unset[5] | Nest key_env: REAPI_API_KEY under providers.reapi and export it[5] |
Model Not Found from gateway[5][9] | Upstream (config.yaml) | Hyphenated slug sent instead of dotted wire ID[9][10] | Use gpt-6.2-sol:gpt-0.1, deepseek-v4.1-flash, or claude-opus-5-5:claude-0.5[8][9][10] |
/model shows one button only[5] | Upstream (config.yaml) | models: list omitted under provider block[5] | Add explicit models: entries (over 8 activates 8-per-page pagination) and restart[5] |
HTTP 409 or SSE admission_conflict[3] | Downstream (hermes gateway) | Reused Idempotency-Key with changed fields or session[3][4] | Issue a fresh key per distinct turn and inspect final SSE error chunks[3][4] |
| Vision paste rejected upstream[3][9] | Cross-boundary | Downstream accepts data:image/... while reAPI requires public HTTP(S) URLs[3][9] | Supply hosted HTTP(S) URLs for multimodal requests sent to reAPI[9][10] |
Keeping ~/.hermes/config.yaml strictly separate from hermes gateway gives NousResearch Hermes Agent a clean two-tier boundary: local memory, skills, and durable admission queues stay on http://127.0.0.1:8642/v1, while upstream token spend bills through one credential from API Keys against https://api.reapi.ai/v1.[3][5][8] Route routine tasks through DeepSeek V4.1 Flash or discounted GPT-6.2 Sol, escalate hard architecture work to Claude Opus 5.5 via /model claude-opus-5-5:claude-0.5, and run hermes doctor before exposing port 8642 to browser clients.[5][8][9][10]
References
- Nous Research. NousResearch/hermes-agent GitHub Repository. Checked December 3, 2026 from github.com/NousResearch/hermes-agent
- Nous Research. Hermes Agent Quickstart Documentation. Checked December 3, 2026 from hermes-agent.nousresearch.com/docs/getting-started/quickstart
- Nous Research. Hermes Agent API Server Documentation. Checked December 3, 2026 from hermes-agent.nousresearch.com/docs/user-guide/features/api-server
- Nous Research. API Server Source Specification (api-server.md). Checked December 3, 2026 from github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/api-server.md
- Aiberm API Documentation. Hermes Agent Setup. Checked December 3, 2026 from aiberm.com/docs/en/hermes
- Tom Langridge (Fastio). Hermes Agent API Server: OpenAI-Compatible Endpoints and Setup. Checked December 3, 2026 from fast.io/resources/hermes-agent-api-server-guide
- Kenji Tanaka (Kie AI). What Is Hermes Agent? Nous Research's Learning-Loop Agent. Checked December 3, 2026 from kie.ai/blog/what-is-hermes-agent
- reAPI. Claude Opus 5.5 API Pricing and Endpoint Reference. Checked December 3, 2026 from reapi.ai/models/claude-opus-5-5
- reAPI. GPT-6.2 Sol API Pricing and Endpoint Reference. Checked December 3, 2026 from reapi.ai/models/gpt-6-2-sol
- reAPI. DeepSeek V4.1 Flash API Pricing and Endpoint Reference. Checked December 3, 2026 from reapi.ai/models/deepseek-v4-1-flash