# Providers & Model Aliases

Set via `hermes model` (picker) or `hermes setup`. 35+ provider profiles ship as
plugins under `plugins/model-providers/`; user plugins of the same name override.
Full docs: https://hermes-agent.nousresearch.com/docs/integrations/providers

### Providers

| Provider | Auth | Key env var(s) |
|----------|------|----------------|
| openrouter | API key | `OPENROUTER_API_KEY` |
| anthropic | API key | `ANTHROPIC_API_KEY` (also `CLAUDE_CODE_OAUTH_TOKEN`) |
| nous | OAuth device code | `hermes auth add nous` (or `NOUS_API_KEY`) |
| openai-codex | OAuth | `hermes auth add openai-codex` |
| qwen-oauth | OAuth | `hermes auth add qwen-oauth` |
| minimax-oauth | OAuth | `hermes auth add minimax-oauth` |
| copilot | Token | `COPILOT_GITHUB_TOKEN` / `GH_TOKEN` (Copilot device flow — `gh auth login` tokens do NOT work) |
| copilot-acp | External CLI | Copilot CLI on PATH or `COPILOT_CLI_PATH` |
| gemini | API key | `GOOGLE_API_KEY` or `GEMINI_API_KEY` |
| xai | API key | `XAI_API_KEY` (SuperGrok OAuth also supported) |
| deepseek | API key | `DEEPSEEK_API_KEY` |
| zai (GLM) | API key | `GLM_API_KEY` / `ZAI_API_KEY` |
| minimax / minimax-cn | API key | `MINIMAX_API_KEY` / `MINIMAX_CN_API_KEY` |
| kimi-coding / -cn | API key | `KIMI_API_KEY` / `KIMI_CN_API_KEY` |
| alibaba (+coding-plan) | API key | `DASHSCOPE_API_KEY` / `ALIBABA_CODING_PLAN_API_KEY` |
| xiaomi | API key | `XIAOMI_API_KEY` |
| huggingface | Token | `HF_TOKEN` |
| fireworks / novita / nvidia / deepinfra / gmi / arcee / stepfun / upstage / kilocode / ai-gateway / opencode-zen / opencode-go / ollama-cloud | API key | `<NAME>_API_KEY` |
| bedrock / vertex / azure-foundry | Cloud SDK / key | AWS SDK creds / Vertex ADC / `AZURE_FOUNDRY_API_KEY` |
| custom | Config | `model.base_url` + `model.api_key` in config.yaml |

Multiple credentials per provider pool and rotate automatically (`hermes auth`).
Fallback chain when the primary fails: `hermes fallback add|remove|list`.

### User-defined model aliases

Work with `/model <name>` in CLI and every gateway platform. Resolved by
`hermes_cli/model_switch.py::resolve_alias()`; user aliases are checked BEFORE
the built-in table, so a user `sonnet`/`grok` shadows the built-in.

```yaml
# Full form
model_aliases:
  fav:
    model: claude-sonnet-4.6
    provider: anthropic
  local-qwen:
    model: qwen3.5:397b
    provider: custom
    base_url: "https://ollama.com/v1"
  theta:
    model: theta-1
    provider: custom
    base_url: "https://theta.example.com/v1"
    key_env: THETA_API_KEY        # or: api_key: "${THETA_API_KEY}"

# Short form ("provider/model"), also via CLI:
#   hermes config set model.aliases.fav openrouter/anthropic/claude-sonnet-4.6
model:
  aliases:
    fav: openrouter/anthropic/claude-sonnet-4.6
```

`/model fav` — session-scoped; add `--global` to persist as default.

An alias with its own `base_url` authenticates with its own credential
(`api_key`, which also accepts a `"${VAR}"` reference, or `key_env`). With
neither set the key is resolved from the alias HOST, never carried over from
the provider that was active before the switch.

Built-in aliases (catalog-resolved against the active provider): `sonnet`,
`opus`, `haiku`, `claude`, `gpt5`, `gpt`, `codex`, `o3`, `o4`, `gemini`,
`deepseek`, `grok`, `llama`, `qwen`, `minimax`, `nemotron`, `kimi`, `glm`,
`step`, `mimo`, `trinity`.

### Multi-Provider-/Zweit-Key-Fallen (Auto-Detect-Route)

Sobald ZWEI Provider-Keys im Profil liegen (z. B. Hauptprovider + zweiter
custom-Provider), kann Auto-Detect das gepinnte Default-Modell zum falschen
Provider routen: erst 401 (= Key fehlt im laufenden Prozess), dann 404
(= Modell beim anderen Provider nicht vorhanden) sind zwei Symptome einer
Ursachenfamilie. Regeln:

- Jeder Alias, der einen bestimmten Provider treffen soll, IMMER in
  Vollform definieren — `model:` + `provider: custom` + `base_url` +
  `key_env`. Kurzformen (`alias: provider/modell`) überlassen die
  Provider-Auflösung dem Auto-Detect und brechen bei Zweit-Keys.
- Vertraue nie nur der Datei-Lage: ENV-Check am LAUFENDEN Prozess via
  `/proc/<gateway-pid>/environ` (Nullbytes mit `tr '\0' '\n'`), plus
  config-Grep auf jeden base_url-Anker.
- Beweis-Tripel nach JEDEM Modellumbau, bevor irgendetwas „läuft“-gemeldet
  wird: (a) Direkt-curl jedes Modells (max_tokens 8–64) gegen die API,
  Antwortinhalt prüfen; (b) E2E-One-Shot durch den Gateway mit
  Antworttext-Sichtung (>90 s Dauer heißt Lock-Wartezeit, NICHT
  Routingfehler); (c) live per python-sqlite3 die sessions-Tabelle der
  state.db befragen (modell + provider + api_call_count) — kein sqlite3-CLI
  voraussetzen.
- Config-Chirurgie statt Voll-Neuschreiben: gezielte Edits an den Anker-
  Zeilen, NIE eine ganze config.yaml neu generieren (Kommentar- und
  Formatverlust = neue Fehlerquelle). Vorher zeistempeltes Backup.

### Prepaid-Balance abfragen („Wieviel Guthaben haben wir noch?“)

Custom-/Prepaid-Provider haben keine einheitliche Billing-API — die hier
verifizierten Endpunkte dieses Setups:

- **Abliteration.ai** (custom-Provider von `config.yaml` `base_url
  https://api.abliteration.ai/v1`): `GET /v1/credits` mit `Authorization:
  Bearer $ABLITERATION_API_KEY` (Key in `~/.hermes/.env`) → JSON
  `data.total_credits` / `data.total_usage` (Rest = Differenz). Ein 402
  „Billing account is not in good standing“ von Subagenten kann TRANSIENT
  sein — vor Neuaufladung/Providerswitch eine minimale Chat-Completion
  (max_tokens 10) gegen `/v1/chat/completions` testen.
- **NanoGPT**: `POST https://nano-gpt.com/api/check-balance` (leerer JSON-Body
  `{}`) mit `Authorization: Bearer <api_key>` (Key `api_key`-Feld in
  `~/.secrets/nanogpt.json`) → `usd_balance`, `usd_pending_usage`.
