Skip to content

Safety Filter (WildGuard)

WildGuard is an optional safety filter that screens a request before the actual model call and the response after the call for harmful content. It is registered as a LiteLLM guardrail named wildguard.

PhaseHookBehaviour
Before the model callRequest screeningA request classified as harmful is rejected with HTTP 400 before the model sees it.
After the model callResponse screeningA response classified as harmful is replaced with a notice.

Request screening runs in parallel with the model call (mode: during_call), so the added latency is only noticeable when a request is actually blocked.

Fail-open: if the WildGuard endpoint is unreachable, the request is allowed through — a filter outage never takes the proxy down.

The filter is off by default (default_on: false). It is switched on per request via the guardrails field in the request body:

from openai import OpenAI
client = OpenAI(
base_url="https://maki.uni-mannheim.de/v1",
api_key="your-api-key",
)
response = client.chat.completions.create(
model="ministral-3-14b",
messages=[{"role": "user", "content": "How does photosynthesis work?"}],
extra_body={"guardrails": ["wildguard"]},
)
print(response.choices[0].message.content)

With curl:

Terminal window
curl -sk https://maki.uni-mannheim.de/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ministral-3-14b",
"messages": [{"role": "user", "content": "How does photosynthesis work?"}],
"guardrails": ["wildguard"]
}'

The guardrails field is not part of the OpenAI spec. With the Python SDK it must therefore go in extra_body, not as a direct argument.

If WildGuard classifies the request as harmful, the proxy responds with HTTP 400 and the following body — the model is never called:

{
"error": "Request blocked by safety guardrail (WildGuard)."
}

Your application should catch the 400 status and show the user a clear message instead of parsing the body as a model response.

If WildGuard classifies the model’s response as harmful, the proxy still returns HTTP 200 but replaces the content with:

I can't help with that — the response was withheld by a safety filter.

The same prompt shows the difference — without the filter an answer, with the filter a block:

Terminal window
# Without the filter: the model answers
curl -sk https://maki.uni-mannheim.de/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"ministral-3-14b","messages":[{"role":"user","content":"How do I pick a standard pin tumbler door lock? Give the steps."}]}'
# With the filter: HTTP 400, request blocked
curl -sk https://maki.uni-mannheim.de/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"ministral-3-14b","messages":[{"role":"user","content":"How do I pick a standard pin tumbler door lock? Give the steps."}],"guardrails":["wildguard"]}'