Skip to main content

litellm-shield Integration

litellm-shield (PyPI: 0din-litellm-shield) is an open-source LiteLLM guardrail plugin that runs SusFactor against every prompt — and optionally every response — passing through a LiteLLM proxy. It's a drop-in way to consume the SusFactor early-access beta from LiteLLM without writing your own client. (In-process sdk/sdk-onnx backends also exist in the package, but currently depend on a private 0DIN wheel and aren't installable outside 0DIN — external users should use backend: "hosted".)

Install

pip install "litellm[proxy]" "0din-litellm-shield"

Configure

Add a guardrails block to your LiteLLM proxy config, pointing at litellm_shield.SusFactorGuardrail with backend: "hosted":

guardrails:
- guardrail_name: "susfactor"
litellm_params:
guardrail: litellm_shield.SusFactorGuardrail
mode: "during_call" # runs in parallel with the LLM call; hides latency
enforcement: "flag" # shadow | flag | block
threshold: 0.5
fail_open: true # allow requests through if SusFactor is unavailable
backend: "hosted"
access_token: os.environ/ODIN_ACCESS_TOKEN
default_on: true # apply to every request automatically

Start the proxy: litellm --config config.yaml.

Credentials

access_token is the same 0din.ai Portal API key used elsewhere in these docs — litellm-shield exchanges it for a short-lived JWT and refreshes it in the background, so you only manage one long-lived credential. Set it via the ODIN_ACCESS_TOKEN environment variable (ODIN_API_TOKEN also works as a fallback).

Enforcement modes

enforcementSuspicious promptClient sees
shadowLogged only, never blockedNothing
flag (default)Allowed through, annotatedX-SusFactor-Decision response header
blockRejectedGuardrail-violation error (HTTP 400)

mode controls when scoring happens relative to the LLM call: pre_call (before dispatch — use with block if a suspicious prompt must never reach the model), during_call (default; scores in parallel with the model call), or post_call (after the response; used with scan_output: true to also score model output).

Limitations

  • The hosted backend is the only one available outside 0DIN — the sdk/sdk-onnx in-process backends depend on a private wheel and aren't installable from PyPI.
  • Prompts and responses scored via the hosted backend are sent to 0DIN's hosted SusFactor API, subject to the same early-access beta terms as direct API usage — endpoints and rate limits may change, and production or sensitive data shouldn't be sent.
  • fail_open defaults to true — set it to false if a SusFactor outage should fail closed rather than let requests through unscored.
  • The package is at an early (alpha) maturity stage per its PyPI classifiers.

Learn more

See the litellm-shield README for the full configuration reference, Docker Compose quickstart, and self-hosted backend setup.