How hooks work
The LLM gateway loads hook configuration from thellm_inference_hooks table for the active organization. When configured:
- Pre-inference hook — Called with the original request body before routing to a provider. A successful hook may return a replacement body. A non-success response can abort the request when
abort_on_pre_erroris enabled. - Post-inference hook — Called with the request body and provider response after inference completes. A successful hook may return a replacement response body.
- Streaming post-hook — For streaming responses, where the body is not available for mutation, a best-effort hook fires with the request and streaming metadata.
Authentication and authorization
Hook configuration is managed through the LLM gateway admin endpoints, which require a Clerk JWT and organization owner or admin role.Configure hooks
Endpoints
Get configuration
200 OK
Set configuration
200 OK
Remove configuration
200 OK
Hook payload and signature
Every hook request includes the payload body and an HMAC-SHA256 signature in theX-Allternit-Hook-Signature header.
hook_secret:
Post-hook payload
Post-hooks receive a JSON envelope containing the original request and provider response:Hook behavior
Pre-hook outcomes
Post-hook outcomes
Error codes
Related pages
- Admin API overview — LLM gateway administration
- LLM Gateway Admin — gateway administration endpoints
- Security model — trust boundaries and data flows
- DLP — content policy enforcement in the gateway