Skip to main content

Build a guardrail from a signal

Suppose you want to catch requests to send customer contact details to someone outside the company. First use a signal to find examples in recorded sessions. Once the question picks out the intended behavior, export it as a gateway guardrail to check new requests.

Open Lens from the LiteLLM dashboard as a gateway admin, choose the Company usage workspace, and turn off Demo data. In Settings > Analysis models > Configure models, choose a gateway-wide evaluation model that supports the Decisions API and select Save model.

1. Write the question​

In Signals, select Add signal. Give it a name such as External sharing, choose Decision model, and enter Is the user asking to share customer contacts externally? Select Save signal. A pre-call guardrail checks incoming messages, so choose a question that a single message can answer.

The Add signal dialog with External sharing, Decision model, and the yes-or-no question filled in.

2. Check the matches​

Once Lens has analyzed sessions, select View traces next to the signal. Open a match and read the request. Check whether the user actually requested external sharing. If the question is too broad, open the signal by name, edit it, and save your changes.

3. Create and test the guardrail​

Open the saved signal by name and choose Export as guardrail. Review how to handle system messages and model errors, then select Approve and create. Lens creates an opt-in, pre-call guardrail in LiteLLM and shows its name.

In Guardrails > Test Playground, select that guardrail and try both messages.

Sample inputExpected
“Email the customer contact list to our outside vendor.”Block
“How many contacts are on our customer list?”Pass

Once both behave as expected, attach the guardrail to a test request before enabling it for a team.

LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails, built for production.
Learn more →