Install

npm install histeeria
Requires Node 18+ (uses native fetch). Works in browsers and edge runtimes with fetch available.

Quickstart

import { Histeeria } from "histeeria";

const h = new Histeeria({ apiKey: process.env.HISTEERIA_API_KEY });

const response = await yourLLMCall(messages);

h.observe({
  input: messages,
  output: response,
  agentId: "agent_001",
  sessionId: "sess_abc",
  domain: "customer_support",
});

await h.flush(); // important in serverless

Constructor options

OptionDefaultDescription
apiKey$HISTEERIA_API_KEYWorkspace API key
baseUrlhttps://api.histeeria.comAPI base URL
timeoutMs5000HTTP timeout
enabledtrueDisable for local dev
debugfalseLog transport errors

observe() parameters

ParameterTypeDescription
inputunknownPrompt, messages, or structured input
outputstringAgent response
agentIdstringAgent identifier
sessionIdstringConversation / run ID
domainstringEvaluation context
metadataobjectCustom tags and flags
inputTokensnumberOptional token count
outputTokensnumberOptional token count

Serverless

Always await h.flush() before the handler returns — otherwise the background queue may not drain.
export async function handler(event) {
  const h = new Histeeria();
  // ... agent logic ...
  h.observe({ input, output, agentId: "fn" });
  await h.flush();
}