Skip to content

Chat Architecture

Event flow

  1. User submits a prompt through the chat composer.
  2. The component posts history and settings to /api/chat.
  3. The chat API gathers evidence and streams back events (evidence, delta, error).
  4. Messages and side panels update as events arrive.
  5. When claim analysis is requested, the client posts the final answer and evidence to /api/claims.
  6. The claims API returns structured claim data that is rendered in the sidebar.

Chat API

  • Endpoint: POST /api/chat
  • Inputs: messages, optional provider, model, settings.
  • Outputs: server‑sent events with tokens and evidence packets.
  • Error codes:
  • 400 – invalid message payload.
  • 500 – upstream failure or missing API key.

Claims API

  • Endpoint: POST /api/claims
  • Inputs: answer string and docs array.
  • Outputs: JSON object following the claims schema.
  • Error codes:
  • 400 – missing answer or docs.
  • 500 – analysis failed or returned malformed JSON.

Examples

After receiving a chat reply, send the answer text and evidence documents to the claims API to extract verifiable claims. Handle 400 responses by validating inputs before submission and surface 500 errors to users through toast notifications.