# Set up Hermes Agent with BharatRouter

Instructions for an AI coding agent to configure **Nous Research's Hermes**
(https://github.com/NousResearch/hermes-agent) to use BharatRouter models.
BharatRouter exposes an OpenAI-compatible API, so Hermes talks to it as a custom provider.

## Prerequisites
- A BharatRouter API key (starts with `br-`). Get one at https://bharatrouter.com/console#keys
- Hermes installed:
  ```
  curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
  hermes setup
  ```

## Configure (non-interactive — preferred for agents)
Run these, substituting the user's real `br-` key:
```
hermes config set model.provider custom:api.bharatrouter.com
hermes config set model.base_url https://api.bharatrouter.com/v1
hermes config set model.model glm-5.3-flash
hermes config set BHARATROUTER_API_KEY br-XXXXXXXX   # stored in ~/.hermes/.env
hermes config get                                    # confirm
```

## Or edit the config files directly
- `~/.hermes/.env` — the key lives here, never in config.yaml:
  ```
  BHARATROUTER_API_KEY=br-XXXXXXXX
  ```
- `~/.hermes/config.yaml` — custom OpenAI-compatible provider:
  ```yaml
  model:
    provider: custom:api.bharatrouter.com
    base_url: https://api.bharatrouter.com/v1
    model: glm-5.3-flash          # or gpt-oss-120b
    api_key: ${BHARATROUTER_API_KEY}
  ```

## Models (set `model.model` to one of)
- `glm-5.3-flash` — fast, 1M-token context. Good default for iteration and whole-repo prompts.
- `gpt-oss-120b` — heavier agentic coding and long tool-loops.

## Verify the endpoint works
```
curl https://api.bharatrouter.com/v1/chat/completions \
  -H "Authorization: Bearer br-XXXXXXXX" -H "Content-Type: application/json" \
  -d '{"model":"glm-5.3-flash","messages":[{"role":"user","content":"Say hello in one line."}]}'
```
A 200 with a chat completion means you're set. Then run `hermes`.

## Notes / gotchas
- Streaming and tool-calling both work over BharatRouter.
- Keep the key in the environment; reference it as `${BHARATROUTER_API_KEY}` — do not hardcode `br-...` in config.yaml.
- No silent fallback: if a model id isn't routed for this key, BharatRouter returns a normal OpenAI-style 4xx. Fix the `model` value; do not assume a fallback.
- Keep client timeouts generous — some models are slow to first token.
- Usage is metered on the key; org/team/person budgets are set at https://bharatrouter.com/console#spend

Human-readable version: https://bharatrouter.com/blog/hermes-agent-bharatrouter
