# Hermes Agent

> Run Hermes Agent, Nous Research's open-source agent, on Tchavi: one block in config.yaml, one environment variable and credits topped up with mobile money.

- Canonical: https://tchavi.com/en/docs/coding-agents/hermes-agent

---


Part of the [coding agents](/docs/coding-agents) guides.

Hermes Agent is Nous Research's open-source agent. It runs in your terminal, as a desktop app or as a messaging gateway, and works with the model you choose. It accepts any OpenAI-compatible endpoint: one block in its `config.yaml` and one environment variable are enough to run it on your Tchavi credits, with a single account and a single balance for every model.

## 1. Create the key

Create a key in the [dashboard](/dashboard/api-keys) and top up your balance from the [billing page](/dashboard/billing) before the first call. [Mobile money payments](/docs/payments) lists the countries and operators. Then export the key in the shell you start Hermes from, or add it to `~/.hermes/.env`:

```bash
export TCHAVI_API_KEY=sk-tch-your-key
```

## 2. Declare Tchavi in config.yaml

Open `~/.hermes/config.yaml` and set the `model` block:

```yaml
model:
  default: 'deepseek-v4.1-flash'
  provider: custom
  base_url: 'https://tchavi.com/api/v1'
  key_env: TCHAVI_API_KEY
```

`provider: custom` tells Hermes the server is not one of its built-in providers. `key_env` names the variable Hermes reads the key from: the key itself never goes in the file.

<Callout type="warning" title="Do not use OPENAI_API_KEY">
  For a custom endpoint, Hermes ignores `OPENAI_API_KEY` and `OPENAI_BASE_URL`: it only sends them
  to OpenAI's own hosts. Use `provider: custom`, `base_url` and `key_env`.
</Callout>

### Alternative: the `hermes model` wizard

If you would rather not edit the file, run `hermes model` and pick **Custom endpoint**. The wizard asks for the base URL (`https://tchavi.com/api/v1`), the key, the model name, the context size (leave it blank to auto-detect) and the API mode, then writes `config.yaml` for you. The wizard stores a pasted key in `~/.hermes/.env` as `HERMES_MODEL_API_KEY`.

### Alternative: `hermes config set`

`hermes config set` writes one value: an UPPER_CASE name goes to `~/.hermes/.env`, a dotted key goes to `config.yaml`.

```bash
hermes config set model.provider custom
hermes config set model.base_url https://tchavi.com/api/v1
hermes config set model.default deepseek-v4.1-flash
hermes config set model.key_env TCHAVI_API_KEY
hermes config set TCHAVI_API_KEY sk-tch-your-key
```

<Callout type="note" title="Check it on your machine">
  Hermes documents the "upper case to `.env`, dots to `config.yaml`" routing, but the exact `hermes
  config set model.key_env …` call was not run while writing this guide. Look at `config.yaml`
  afterwards (`hermes config show`) to confirm the result.
</Callout>

## 3. Verify

```bash
hermes doctor
hermes chat -q "Answer with one word: OK"
```

`hermes doctor` checks the install and the configuration. `hermes chat -q` sends a single question and returns: it is the cheapest test, especially with a small model.

At startup Hermes prints a `Context limit: … tokens` line with the window size it detected. Hermes requires at least 64,000 tokens of context and refuses a model below that. If the value is missing or wrong, set it yourself under `model`:

```yaml
model:
  context_length: 1048576
```

<Callout type="tip" title="A smaller window costs less">
  Hermes compresses long conversations itself. Setting `context_length` lower than the model's
  window (200,000, for example) triggers that compression earlier, so fewer tokens are sent back on
  every turn. It is a tuning choice, not a rule.
</Callout>

## Point the auxiliary models at Tchavi too

Hermes makes small calls beside the conversation: summarising a history that has grown too long (`compression`), titling the session (`title_generation`), describing an image (`vision`), classifying a command that needs approval (`approval`). Each has its own block under `auxiliary`, and the default is `provider: auto`, which means "the same model as the main model".

If your main model is a big one, those housekeeping calls are therefore billed at its price. Send them to a small model, and give the key explicitly: an auxiliary block's key does not fall back to `TCHAVI_API_KEY`.

```yaml
auxiliary:
  compression:
    provider: custom
    base_url: 'https://tchavi.com/api/v1'
    api_key: ${TCHAVI_API_KEY}
    model: qwen3.7-flash
  title_generation:
    provider: custom
    base_url: 'https://tchavi.com/api/v1'
    api_key: ${TCHAVI_API_KEY}
    model: qwen3.7-flash
  vision:
    provider: custom
    base_url: 'https://tchavi.com/api/v1'
    api_key: ${TCHAVI_API_KEY}
    model: qwen3.7-flash
```

`${TCHAVI_API_KEY}` is replaced by the value of the environment variable. If it is not set, Hermes keeps the text as it is and logs a warning.

<Callout type="note" title="provider: custom next to base_url">
  `base_url` wins over `provider`. Keeping `provider: custom` beside it is our reading of Hermes's
  code, not an example from its documentation: if an auxiliary block does not go to Tchavi, remove
  that line and look at **Usage** in the dashboard.
</Callout>

The `approval` block is written the same way, with a small model, if you use automatic command approval.

## 4. Plan a fallback

If a model returns an error or does not answer, Hermes can switch to another. Add an entry with `hermes fallback add` (same picker as `hermes model`), or write it:

```yaml
fallback_providers:
  - provider: custom
    model: deepseek-v4-pro
    base_url: 'https://tchavi.com/api/v1'
    key_env: TCHAVI_API_KEY
```

Hermes switches on `429`, `500`, `502` and `503` after its retries, and straight away on `401`, `403` and `404`. It does so at most once per turn and goes back to the main model on the next message. `hermes fallback check` verifies that each entry's credentials are ready.

A fallback that stays on Tchavi protects you from a single model going down, not from the gateway itself going down.

## Models

An agent sends the same system prompt, the same tools and the history already exchanged on every turn. What weighs on the bill is therefore mostly the cached input price, far more than the fresh input price. Prices below are in F CFA per million tokens: input, output, cached input.

| Role                                 | Model                 | Input | Output | Cached | Notes                                                                              |
| ------------------------------------ | --------------------- | ----- | ------ | ------ | ---------------------------------------------------------------------------------- |
| Everyday choice                      | `deepseek-v4.1-flash` | 110   | 439    | 4.7    | 1,048,576 tokens of context, reads images. It reasons by default: keep effort low. |
| Hard coding tasks                    | `claude-sonnet-5-5`   | 1,466 | 7,333  | 73     | See the cache warning below.                                                       |
| Alternative for hard tasks           | `gpt-6-sol`           | 1,466 | 7,333  | 147    | Same input and output price, cache reads twice as dear.                            |
| Hard, cheaper                        | `deepseek-v4-pro`     | 967   | 2,900  | 32     | No image input.                                                                    |
| Auxiliary: summaries, titles, vision | `qwen3.7-flash`       | 22    | 97     | 5.3    | 1,000,000 tokens of context, reads images.                                         |

`deepseek-v4.1-flash` reasons before it answers, and those thinking tokens are billed as output. For routine work, keep the reasoning effort low. For `qwen3.7-flash`, the reasoning behaviour has not been measured: watch your first bills in **Usage**. Any chat model that calls tools and has at least 64,000 tokens of context works; `GET /v1/models` returns the full list, and prices are in the [catalogue](/models).

### Eco mode, for background tasks

Adding `:eco` to the id (`deepseek-v4.1-flash:eco`) bills the request at half the list price. Hermes sends the id as it is (per its code, not tested end to end), so `default: 'deepseek-v4.1-flash:eco'` should work. The answer is 2 to 4 times slower, and at busy times Tchavi can reply `429` with `eco_mode_saturated`: the request is then not charged. Keep it for background or scheduled tasks, and add a fallback entry pointing at the id without `:eco`. Details in [Eco mode](/docs/chat-completions#eco-mode).

<Callout type="warning" title="No service_tier at provider level">
  Do not put `service_tier: flex` in a provider's `extra_body`: it would apply to every model, and
  any model without Eco mode would answer with a `400`. Use the `:eco` suffix, model by model.
</Callout>

### A complete example

```yaml
model:
  default: 'deepseek-v4.1-flash'
  provider: custom
  base_url: 'https://tchavi.com/api/v1'
  key_env: TCHAVI_API_KEY
  context_length: 1048576

auxiliary:
  compression:
    provider: custom
    base_url: 'https://tchavi.com/api/v1'
    api_key: ${TCHAVI_API_KEY}
    model: qwen3.7-flash
  title_generation:
    provider: custom
    base_url: 'https://tchavi.com/api/v1'
    api_key: ${TCHAVI_API_KEY}
    model: qwen3.7-flash
  vision:
    provider: custom
    base_url: 'https://tchavi.com/api/v1'
    api_key: ${TCHAVI_API_KEY}
    model: qwen3.7-flash

fallback_providers:
  - provider: custom
    model: deepseek-v4-pro
    base_url: 'https://tchavi.com/api/v1'
    key_env: TCHAVI_API_KEY
```

## What Hermes loses behind a gateway

Worth knowing before you choose, rather than finding out in the middle of a task:

- **No cache markers for Claude.** On a custom endpoint, Hermes does not add Claude's `cache_control` markers by default. Prefer models that cache the start of the prompt on the server without any marker (DeepSeek, GPT, Qwen, Kimi). With `claude-sonnet-5-5`, the cache-read rate may therefore not apply: look at the credits charged in **Usage** before leaving it running for long.
- **`OPENAI_API_KEY` and `OPENAI_BASE_URL` are ignored** for a custom endpoint. Only `key_env` or `api_key` count.
- **Reasoning parameters only travel through `extra_body`.** For a custom host, Hermes only sends them in that field, and only when it judges the model supports them. We did not verify what it sends to Tchavi on this point: if the effort setting seems to do nothing, look at the output tokens in **Usage**.
- **At least 64,000 tokens of context.** A smaller model is refused at startup.
- **Auxiliary blocks do not reuse the main key.** Each one has its own `api_key`.

## When something fails

| What you see                    | What it means                                 | Fix                                                                                |
| ------------------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------- |
| `401` / `invalid_api_key`       | The key is wrong, missing or not a Tchavi key | Export `TCHAVI_API_KEY` in the shell Hermes runs from; it starts with `sk-tch-`    |
| `402` / `insufficient_credits`  | Your balance is too low for this request      | Top up from the [billing page](/dashboard/billing); see [payments](/docs/payments) |
| `404` / `model_not_found`       | No model has that id                          | Check the spelling against `GET /v1/models`                                        |
| `403` / `model_not_allowed`     | That model exists but is not available        | Pick another id from `GET /v1/models`                                              |
| `404` on every request          | The base URL is wrong                         | Use `https://tchavi.com/api/v1`, with the `/v1`                                    |
| `400` / `unsupported_parameter` | A parameter does not exist for that model     | Remove it, and do not add `service_tier: flex` to any provider                     |
| `429` / `eco_mode_saturated`    | Eco mode is saturated, nothing was charged    | Retry, or use the id without `:eco`; add a fallback                                |
| `429`                           | Rate limit: per key, per user and per IP      | Wait for the `Retry-After` seconds; Hermes retries by itself                       |

Every request Hermes sends appears under **Usage** in the dashboard, with its model, token counts and credits charged. Keep a separate key for Hermes: the log then shows what it spends, apart from your other tools.

---

Back to [coding agents](/docs/coding-agents)

