Skip to content

Hermes Agent

Run Nous Research's Hermes Agent against AnyRouter as a custom OpenAI-compatible provider — one key across every model, unified billing, and audit logs.

Hermes Agent by Nous Research is an autonomous agent with persistent memory, scheduled tasks, and 20+ messaging integrations (Telegram, Discord, Slack, WhatsApp, Signal, Email, CLI, …). It speaks the OpenAI-compatible wire protocol, so pointing it at AnyRouter is a config-only change — and every call then routes through one gateway with unified billing.

Why route through AnyRouter

  • One key. Reuse the same sk-ar- key for every model Hermes can run.
  • Audit logs. Every Hermes call lands in your dashboard with cost, latency, and tokens.
  • Free model swaps. Change model: in ~/.hermes/config.yaml to any AnyRouter id without rotating keys.

Set it up

Hermes stores model + provider config in ~/.hermes/config.yaml and secrets in ~/.hermes/.env.

AnyRouter is an OpenAI-compatible endpoint, so you register it as a named custom provider and then select it from the model: block. The two pieces are separate:

  • custom_providers: is a list of endpoints, each with a name, base_url, and credentials.
  • model.provider: custom:<name> points at one of those entries, and model.default picks the model id.

Step 1 — Register AnyRouter as a custom provider

Edit ~/.hermes/config.yaml:

model:
  provider: custom:anyrouter          # references the custom_providers entry named "anyrouter"
  default: anyrouter/hermes           # auto-routes the top tool-calling models, best first
  api_mode: chat_completions

custom_providers:
  - name: anyrouter
    base_url: https://anyrouter.dev/api/v1
    key_env: ANYROUTER_API_KEY        # env var holding your sk-ar- key
    api_mode: chat_completions

anyrouter/hermes is a built-in auto-routing model tuned for autonomous agents: it ranks the strongest tool-calling models and routes to the best one first, falling back automatically if one is unavailable. No BYOK keys required — it's billed to your AnyRouter credits at each underlying model's rate. Prefer it over a single fixed model so Hermes keeps running through provider hiccups. Any concrete id (e.g. anthropic/claude-sonnet-4.6) or a BYOK auto-router (anyrouter/agent) also works.

Single provider shortcut: with only one entry in custom_providers, provider: custom (without the :anyrouter suffix) also resolves to it. The explicit custom:anyrouter form is clearer and keeps working when you add more providers.

Step 2 — Add your key

Add the key to ~/.hermes/.env:

ANYROUTER_API_KEY=sk-ar-your-anyrouter-key

Keep secrets in .env and everything else in config.yaml — when both define a value, config.yaml wins for non-secrets. Three ways to supply the key, all equivalent:

  • key_env: ANYROUTER_API_KEY — name the env var Hermes should read (shown above, recommended)
  • api_key: ${ANYROUTER_API_KEY} — interpolate the .env value inline
  • api_key: sk-ar-... — hardcode it (keeps the key in your config file; least preferred)

You can also set these from the CLI without editing files:

hermes config set model.default anyrouter/hermes
hermes config check

hermes config check verifies the configuration is complete; hermes config edit opens config.yaml in your editor.

Step 3 — Run

hermes chat
# or pick a different AnyRouter model on the fly
hermes chat --model openai/gpt-5.4-mini

To switch models mid-session, use the custom:<provider>:<model> triple syntax so Hermes routes through the right provider:

/model custom:anyrouter:anthropic/claude-sonnet-4.6

Every Hermes request now routes through AnyRouter and is billed against your credits.

Verify

Send a message in hermes chat, then open your request logs. The call should appear within a second or two with the model name, token counts, and cost — confirmation Hermes is routing through AnyRouter.

Optional configuration

An AnyRouter fallback

fallback_providers is a list Hermes tries in order on upstream failures. Point one at AnyRouter (or chain AnyRouter behind another provider) for resilience:

fallback_providers:
  - provider: custom:anyrouter
    model: anyrouter/byok

Provider routing

AnyRouter can route each request across its upstream providers — sort by price/throughput/latency, pin or exclude providers, enforce data policies. It reads these preferences from a provider object in the request body.

Don't use Hermes's top-level provider_routing: block here. That block is forwarded only when provider: openrouter; on a custom: provider it has no effect, so it would silently do nothing for AnyRouter.

Instead, attach the provider object via extra_body on the AnyRouter entry — Hermes merges extra_body into every chat-completions request:

custom_providers:
  - name: anyrouter
    base_url: https://anyrouter.dev/api/v1
    key_env: ANYROUTER_API_KEY
    api_mode: chat_completions
    extra_body:
      provider:
        sort: throughput              # price (default) | throughput | latency
        # only: [anthropic]           # only use these providers
        # ignore: [deepinfra]         # skip these providers
        # order: [anthropic, google]  # try providers in this order
        # require_parameters: true    # only providers supporting all request params
        # data_collection: deny       # exclude providers that may store/train on data

See Provider Routing for the full field list — including zdr, max_price, throughput/latency percentile thresholds, and the :nitro / :floor model-id shortcuts.

Vision models

AnyRouter serves many vision-capable models, but because Hermes reaches them through a custom endpoint it can't look up their capabilities in models.dev. Without a hint, Hermes pre-describes attached images through vision_analyze instead of sending them natively. Set supports_vision: true so images route as native image_url parts:

model:
  provider: custom:anyrouter
  default: anthropic/claude-sonnet-4.6
  supports_vision: true            # send images natively to vision models

The same flag works per-model on a provider entry (custom_providers[*].models[*].supports_vision). It's the only knob you need — no separate agent.image_input_mode: native.

  • anthropic/claude-sonnet-4.6 — balanced quality and latency, strong tool use
  • anthropic/claude-haiku-4.5 — cheapest, fastest, good default for memory + skill loops
  • openai/gpt-5.4 — best for long reasoning chains

List every available model:

curl https://anyrouter.dev/api/v1/models -H "Authorization: Bearer sk-ar-your-key"

Troubleshooting

429 (rate limits) — Hermes runs tight loops with subagents and skills, which can burst beyond a single key's per-minute budget. If you see 429 Too Many Requests, back off and retry — the same key works again next window. Do not treat 429 as a permanent failure. See Rate Limits.