Skip to content

Getting started

You need two things: the base URL of a running Hermes WebUI server, and (if the instance has a password) that password. Everything below is plain HTTP — use curl, fetch, URLSession, OkHttp, or anything that speaks HTTP/1.1.

1. Find the server

A Hermes WebUI server listens on a host you control — e.g. http://127.0.0.1:8787 locally, or https://hermes.example.com behind a reverse proxy. That origin is your API base URL. Every path in this reference is relative to it.

2. Check whether auth is required

curl -s https://your-host/api/auth/status

Illustrative response from an open server (other fields omitted):

{ "auth_enabled": false, "logged_in": false }
  • auth_enabled: false → no sign-in is configured; call the API directly. logged_in is always false on an open server, so it does not mean an auth failure there.
  • auth_enabled: true and logged_in: true → the request already carries a valid session.
  • auth_enabled: true and logged_in: false → sign in with a method the instance has configured. The password login in the next step works only when password_auth_enabled is true. Passkey, OIDC and trusted-header sign-in use their own routes (see Authentication).

/api/auth/status is public — you can always call it to probe an instance.

3. Log in (if needed)

Only when auth_enabled and password_auth_enabled are both true:

curl -s -c cookies.txt -X POST https://your-host/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"password": "your-server-password"}'

On success the server sets a session cookie (hermes_session by default). Send that cookie on every subsequent request. In a native client, use a cookie-storing HTTP session (URLSession and OkHttp do this automatically) — see Authentication.

4. List sessions

curl -s -b cookies.txt https://your-host/api/sessions
{ "sessions": [ { "session_id": "…", "title": "…", "updated_at": 1794632218.45, "pinned": false }, … ] }

Illustrative values. updated_at is Unix epoch seconds (a number, possibly fractional), not an ISO string. A brand-new session with no messages may not appear in this list yet.

5. Start a streaming conversation

This is the core loop. Two steps: start a turn, then open the SSE stream to receive tokens live.

# (a) start a turn — returns a stream id
curl -s -b cookies.txt -X POST https://your-host/api/chat/start \
  -H 'Content-Type: application/json' \
  -d '{"session_id": "…", "message": "Hello!"}'
# → { "stream_id": "…" }

# (b) open the live stream (Server-Sent Events)
curl -N -b cookies.txt "https://your-host/api/chat/stream?stream_id=…"
# → named SSE frames, each an `event:` line plus a JSON `data:` line: token/tool
#   events, a `done` payload, then `stream_end` on the normal successful path

The full frame format is documented in Streaming (SSE). That's the whole model — a native client renders those frames into the live assistant bubble exactly like the web UI does.

Minimal client, end to end

This browser example runs inside an already signed-in WebUI page on the same origin. Reload the WebUI after signing in so the page carries the current session-bound CSRF token. Cookie credentials alone do not make an arbitrary cross-origin website an API client. The configuration object below is supplied by the WebUI page, not by a public token endpoint; on an instance without a password the token is an empty string and is not required. For a standalone native client, use the cookie-storing HTTP workflow above, and do not forge browser Origin/Referer headers to get past the checks.

// Run inside a signed-in WebUI tab (same origin), for example from its
// developer console. Not for third-party sites. Paths assume the WebUI is
// served at the site root. Supply onFrame(type, payload) to render your UI.
async function startExample(onFrame) {
  // Supplied by the WebUI shell. It is an empty string when the instance has
  // no password; the server then does not require the header.
  const csrf = window.__HERMES_CONFIG__?.csrfToken || "";

  async function json(path, init = {}) {
    const headers = new Headers(init.headers);
    if (init.body) headers.set("Content-Type", "application/json");
    if (csrf && /^(POST|PUT|PATCH|DELETE)$/i.test(init.method || "GET")) {
      headers.set("X-Hermes-CSRF-Token", csrf);
    }
    const response = await fetch(path, { ...init, credentials: "same-origin", headers });
    const payload = await response.json();
    if (!response.ok) throw new Error(payload.error || `HTTP ${response.status}`);
    return payload;
  }

  const { sessions } = await json("/api/sessions");
  if (!sessions?.length) throw new Error("Create a conversation in the WebUI, then try again.");
  const { stream_id } = await json("/api/chat/start", {
    method: "POST",
    body: JSON.stringify({ session_id: sessions[0].session_id, message: "Hi" })
  });
  const es = new EventSource(`/api/chat/stream?stream_id=${encodeURIComponent(stream_id)}`);
  const terminal = new Set(["stream_end", "cancel", "apperror", "error"]);
  for (const type of ["token", "reasoning", "tool", "tool_complete", "title", "done", ...terminal]) {
    es.addEventListener(type, event => {
      // A transport error is a plain Event, not a server "error" frame.
      // EventSource may reconnect; production clients need a bounded policy.
      if (type === "error" && typeof event.data !== "string") {
        onFrame("transport_error", { readyState: es.readyState });
        return;
      }
      let payload;
      try {
        payload = JSON.parse(event.data);
      } catch (error) {
        es.close();
        onFrame("parse_error", { type, error: String(error) });
        return;
      }
      onFrame(type, payload);
      if (terminal.has(type)) es.close();
    });
  }
  return es;
}

The server sends named SSE frames, so register addEventListener('token', …), addEventListener('done', …) and the other named handlers. onmessage only receives unnamed messages and will miss every frame. done carries the settled transcript; stream_end normally follows it and ends a successful turn. A failed turn ends with apperror (or cancel after a cancellation). This is a small wiring example: production clients also need approval/clarification UI, replay/reconciliation and bounded reconnect behaviour.

Next: read Conventions for the shared rules (session IDs, error shapes, headers), then jump to the endpoint reference for the surface you're building.