Skip to main content
The SDK provides HTTP middleware adapters that extract compliance metadata from LLM responses and inject them as HTTP headers. This enables downstream services, API gateways, and monitoring tools to observe compliance status.

How It Works

  1. Your API endpoint calls the SDK-wrapped LLM client
  2. The SDK attaches _complior metadata to the LLM response
  3. The HTTP middleware intercepts outgoing responses
  4. Metadata is extracted and injected as HTTP headers

Compliance Headers

Express

The Express adapter intercepts res.write() and res.end() to capture the response body, extract compliance metadata, and set headers before the response is finalized.

Fastify

Uses Fastify’s onSend hook to intercept the serialized payload.

Hono

The Hono adapter uses async/await middleware — it calls next(), then clones the response to extract metadata and set headers.
Streaming responses may not be clonable — header injection is silently skipped in that case.

Next.js

Wraps res.json() and res.send() to inject headers before the response is sent.

Header Filtering

All adapters accept a MiddlewareOptions object:
  • If include is set, only listed headers are injected
  • If exclude is set, listed headers are removed from output
  • Both can be combined — include is applied first, then exclude

Configuration

SDK configuration reference.

Providers

Supported LLM providers.