Skip to content

LLM Providers

源码版本v2026.7.20

Responsibility

Turn "a provider name (nvidia, kimi, openai, openrouter...)" into "a concrete hostname, message preprocessing, extra_body, model list". Hermes does not use an inheritance hierarchy for provider abstraction; instead it uses a ProviderProfile dataclass + a set of hooks. Profiles are registered as plugins — "declare to integrate". Nous Portal, OpenRouter, OpenAI, and custom endpoints are supported.

Key Files

Data Flow

  1. init_agent:276 takes the user-configured provider name.
  2. It calls get_provider_profile:65 (triggering lazy discovery on first call: scan plugins/model-providers/<name>/, import it, and register_provider).
  3. Once it has the ProviderProfile:
  4. The main loop calls the provider API with the assembled request (retry sub-loop:1227).
  5. Merging of a custom provider's extra_body happens in _merge_custom_provider_extra_body:257.

Summary

The provider abstraction is "profile + hooks", not "inheritance". Adding a provider only requires creating a subdirectory in plugins/model-providers/, declaring a ProviderProfile, and calling register_provider — no need to touch base. Lazy discovery keeps startup fast and loads on demand.

Unofficial community learning site. Content based on the MIT-licensed NousResearch/hermes-agent source.