Home / Learn / Hermes Agent with Claude through a gateway: custom provider setup, cost controls and fixes
Hermes Agent. A wing-like folded paper message moving through a small gateway arch toward an orderly code workspace, a metaphor for agent routing.

Hermes Agent with Claude through a gateway: custom provider setup, cost controls and fixes

Hermes Agent keeps secrets in ~/.hermes/.env and everything else in ~/.hermes/config.yaml. The reliable way to run it on Claude through a gateway is a named custom provider that speaks the Anthropic Messages format. The shortcut, provider: anthropic with a different base URL, looks right but sends requests to Anthropic for any host it doesn't recognise.

Install

Linux / macOS / WSL2
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
Windows
iex (irm https://hermes-agent.nousresearch.com/install.ps1)

hermes setup runs the full wizard; hermes model handles only provider and model; hermes doctor checks an existing install.

Add the gateway as a custom provider

~/.hermes/.env
AIPRIME_API_KEY=your_gateway_key
~/.hermes/config.yaml
providers:
  aiprime:
    api: https://aiprimetech.io/v1
    key_env: AIPRIME_API_KEY
    transport: anthropic_messages
    catalog_provider: anthropic

model:
  provider: custom:aiprime
  default: claude-sonnet-5
Key Why
transport: anthropic_messagesSpeak Anthropic's Messages format. Without it Hermes falls back to the OpenAI Chat Completions format
key_envThe name of the variable in .env that holds the key
catalog_provider: anthropicThe gateway's Claude models inherit Anthropic's context and vision metadata
provider: custom:aiprimeSelects the named provider; /model custom:aiprime:<model> switches inside a chat

The wizard does the same: hermes model, then **Custom endpoint**, then the API mode **Anthropic Messages**. If you choose Chat Completions instead, keep /v1 in the URL.

Why provider: anthropic with a base URL doesn't work

Setting provider: anthropic and base_url: https://aiprimetech.io looks correct but has no effect: in current Hermes source, a base-URL override on the built-in Anthropic provider is accepted only for Anthropic, Claude and Azure hosts, so requests still go to Anthropic. Use the named custom provider above.

ANTHROPIC_BASE_URL is documented as an override for the Anthropic base URL, but an open Hermes bug means the model picker ignores it. The custom provider avoids both problems.

What drives token use, and the settings that limit it

Hermes runs work beyond the conversation you see, and all of it bills to the same key unless you route it elsewhere.

Source of usage Setting
Subagents (delegation)delegation.max_concurrent_children (default 10), delegation.max_iterations (default 250), delegation.max_spawn_depth (default 1); a cheaper delegation.model
Background memory and skill review after each turnauxiliary.background_review.enabled: false, or a lower max_input_tokens
Auxiliary tasks (compression, titles, vision)auxiliary.<task>.provider and .model to send them to a cheaper model
Scheduled jobscron.model for all jobs; hermes cron pause <id> or hermes pause
Messaging gateway (Telegram, Discord and others)Allow-lists such as TELEGRAM_ALLOWED_USERS; avoid GATEWAY_ALLOW_ALL_USERS=true
~/.hermes/config.yaml (additions)
delegation:
  max_concurrent_children: 3
  model: claude-haiku-4-5
auxiliary:
  background_review:
    enabled: false
cron:
  model: claude-haiku-4-5

hermes prompt-size shows the fixed cost every call carries; /usage and /compress help inside a long session.

Claude Pro or Max login instead of a key

Hermes can sign in to a Claude account, but its documentation says that path works only on a Max plan with purchased extra-usage credits, and that Pro subscribers can't use it. With an API key from a gateway there is no subscription window; usage is billed per token from your balance.

Models

Model ID Use it for
claude-sonnet-5Default for coding and agent work: fast, strong, mid-priced.
claude-opus-5-5Harder reasoning, large refactors, long agent runs.
claude-fable-5-1Most capable and most expensive; save it for the hardest tasks.
claude-haiku-4-5Cheap and quick: titles, summaries, classification, small steps.

Hermes needs a context window of at least 64K tokens; every model in the table qualifies.

Troubleshooting

What you see Cause Fix
HTTP 400 on the first runThe model name doesn't match a gateway model IDUse an ID from the table above
Requests go to Anthropic or fail with an Anthropic auth errorprovider: anthropic with a third-party base URLUse the named custom provider
Garbage or empty repliesWrong transport for the URLtransport: anthropic_messages for Claude
Context length exceededSession larger than the configured windowSet model.context_length; /compress
403 Your request was blockedA firewall in front of the endpoint rejects the clientAdd extra_headers with a browser-like User-Agent
Missing settings after an updateConfig schema changedhermes config check, then hermes config migrate
Bot silent on Telegram or DiscordGateway not running or sender not allowedhermes gateway status; check ~/.hermes/logs/gateway.log

Comparing agent frameworks? See the OpenClaw setup guide.

Frequently asked questions

How do I use Hermes Agent with a custom Claude endpoint?
Add a named provider in ~/.hermes/config.yaml with api set to the gateway URL, key_env pointing at a variable in ~/.hermes/.env, and transport: anthropic_messages, then set model.provider: custom:<name>.
Why does Hermes ignore my Anthropic base_url?
With provider: anthropic, Hermes accepts a base-URL override only for Anthropic, Claude and Azure hosts, so a third-party URL is dropped. Use a named custom provider instead.
How do I reduce Hermes Agent token usage?
Limit subagents (delegation settings), route auxiliary tasks and cron jobs to a cheaper model, turn off background review, and check hermes prompt-size.
Can Hermes Agent use a Claude Pro subscription?
According to Hermes' documentation, no: the Claude login path works only on Max with extra-usage credits. An API key avoids subscription limits altogether.
Start using Claude in minutes

Get an API key — no Anthropic account or waitlist required.

Get your API key

AI Prime Tech is an independent API gateway. It is not affiliated with, endorsed by, or a reseller of Anthropic. Claude and related model names are trademarks of their respective owners.

More Claude API guides

How to Get a Claude API KeyClaude API Pricing, ExplainedThe Cheapest Way to Use the Claude APIUnlimited Cursor with the Claude APIUnlimited Claude Code AccessClaude API Gateway vs. Anthropic DirectUse Claude with the OpenAI SDK: OpenAI-compatible endpoint, streaming, tools and limitsClaude models explained: a Claude model comparison of Claude Opus vs Sonnet vs Haiku vs Fable — all Claude API models, Anthropic model names and prices (2026)Paying for the Claude API with CryptoClaude API Access Without a WaitlistHow to Reduce Claude Token UsageUnlimited Cline with the Claude APIUnlimited Roo Code with the Claude APIUnlimited Claude in JetBrains IDEsAider with Claude through a gateway: ANTHROPIC_API_BASE, config files, architect mode and fixesUnlimited Claude in VS CodeOpenCode config for Claude: opencode.json setup, models and common errorsRunning Unlimited OpenClaw on ClaudeWhat an Anthropic-Compatible API MeansClaude Code API key — ANTHROPIC_API_KEY: how to get it, set it up, and when to use claude setup-token insteadClaude Code API Costs — Pricing and How to Cut ThemClaude API errors explained: server error 500, overloaded 529, rate limit 429, bad request 400 — and the fix for eachHow to buy Claude API credits — and why a Claude credit beats any "buy Claude account" offerClaude free API: is there a free Claude API key, and what is actually free in 2026?Claude API vs Claude Pro/Max Subscription — Which to ChooseCodex CLI with a custom provider: config.toml, GPT and Claude models, IDE extension and fixesConnecting Claude to n8nRouting LiteLLM to ClaudeUsing Claude in Kilo CodeGitHub Copilot Chat with Claude through a gateway: Custom Endpoint setup, agent mode and fixesWire Zed to Claude Through the GatewayConnect Cherry Studio to ClaudeChatAnthropic in LangChain: import, base_url, streaming, tools and errorsAnthropic Python SDK: install, set base_url, stream, and handle errorsClaude with the Vercel AI SDK: createAnthropic baseURL, streaming and fixesRun Factory Droid on ClaudeThe Claude Code API, ExplainedIntegrating the Claude API Into Your ApplicationHow to get unlimited Claude usage — and why there is no "Claude Code cracked"