Skip to main content

JavaScript SDK

The JavaScript SDK is a lightweight, zero-dependency client for capturing RAG interactions and sending them to Quorum for evaluation.

Quick start

Integration patterns

Direct capture

Call capture() after each RAG interaction. It is designed to be non-blocking.

Express middleware

This pattern wraps res.json() and captures responses automatically when req.ragContext is available.

LangChain callback

Extend BaseCallbackHandler and call quorum.capture() in handleChainEnd.

Configuration

OptionTypeDefaultDescription
endpointstringrequiredQuorum backend URL
apiKeystringnoneOptional API key
defaultStrategystringautoauto, single, hybrid, or council
batchSizenumber10Flush when the buffer reaches this size
flushIntervalnumber5000Auto-flush interval in milliseconds
onErrorfunctionconsole.warnError callback
correlationIdstringauto-generatedPropagated as X-Correlation-ID

Data flow

Core methods

new Quorum(config)

Creates a new SDK instance.

.capture(payload)

Buffers a RAG interaction. Returns void.

.flush()

Sends buffered captures to the backend and returns a Promise.

.close()

Flushes remaining captures and stops the interval timer.