Skip to main content

How it attaches

beacon-gateway is the target of Portkey’s webhook guardrail check (default.webhook). Portkey runs a guardrail’s checks before the provider call (beforeRequestHook) and after it (afterRequestHook), POSTs the hook’s context to the webhook, and reads back {"verdict": true|false}. beacon-gateway always answers 200 with {"verdict": true}, so the call goes ahead. Portkey blocks on a false verdict only when the check is configured with deny: true; leave it unset.

What is supported

Configure beacon-gateway

beacon-gateway.yaml
Set token whenever the webhook is reachable by anything other than Portkey; ${VAR} is expanded from the environment, so the token stays out of the file.

Deploy

1

Start beacon-gateway where Portkey can reach it

With the open-source gateway self-hosted (npx @portkey-ai/gateway, the Docker image, or a Kubernetes deployment), run beacon-gateway beside it and keep the webhook on loopback or the cluster network. Portkey’s hosted gateway calls the webhook from Portkey’s infrastructure, so it needs a public HTTPS URL in front of beacon-gateway (a reverse proxy or load balancer terminating TLS), and the token.
2

Add the webhook as an input and an output guardrail

In a Portkey config, add the webhook check to both hooks:
Portkey config
In the Portkey app, create a guardrail with the Webhook check, the same URL and the Authorization header, and attach it to the config as both an input and an output guardrail. Do not turn on deny for an observe-only setup.A webhook that times out or answers an error is an errored check, which Portkey treats as passing unless the check sets failOnError. Leave that off so a beacon-gateway outage never blocks model calls.
3

Send session and identity metadata from clients

Clients (or the app in front of Portkey) send them in the metadata header:
Without session_id, calls are grouped by the conversation’s opening only when _user (or another mapped identity) is present; otherwise every call is its own session.
4

Check it

Limits

  • Pairing request and reply. Portkey does not pass its trace or span id to the webhook, so beacon-gateway pairs a reply with its request by a digest of the request body. Two calls with byte-identical bodies share a call id, and a guardrail that rewrites the request before the output hook breaks the pairing.
  • Streamed replies are not recorded (see above). Collect them from the endpoint, or have clients that need reply coverage call without stream.

Troubleshooting

LLM gateways

What gateway collection records and the settings shared by every gateway.

Envoy

Attach through Envoy, Envoy Gateway or Istio instead.