conduct-litellm-guard
Conduct Guard as a LiteLLM guardrail. Every LLM call routed through LiteLLM runs through your active Guard policy before the request leaves your network — block, warn, audit, or trigger a HITL approval, with the same signed configuration and hash-chained audit log as the rest of Conduct.
Install
pip install conduct-litellm-guard
Wire it up
-
Mint an agent token in the Conduct console (Settings → Agent identities). Copy the
cond_agt_…value. -
Export it in the environment where your LiteLLM proxy runs:
export CONDUCT_AGENT_TOKEN=cond_agt_...
-
Add the guardrail to your LiteLLM proxy's
config.yaml. Two forms — both work today, they differ only in theguardrail:string:Explicit (works on any LiteLLM version):
guardrails: - guardrail_name: conduct-guard litellm_params: guardrail: conduct_litellm_guard.ConductGuard mode: pre_call api_url: https://gateway.conductai.ai agent_token: os.environ/CONDUCT_AGENT_TOKEN unreachable_fallback: fail_closed
Native (once BerriAI/litellm#38143 merges):
guardrails: - guardrail_name: conduct-guard litellm_params: guardrail: conduct mode: pre_call api_key: os.environ/CONDUCT_AGENT_TOKEN unreachable_fallback: fail_closed
The native form uses LiteLLM's idiomatic
api_base/api_keyparameter names. You still install this package —pip install conduct-litellm-guard— because the native adapter is a thin wrapper that imports from it. Same pattern Aporia and Lakera use. -
Start the proxy:
litellm --config config.yaml
A full example lives in examples/config.yaml.
What the guardrail does
For every incoming request the guardrail calls Conduct's guard_check
tool (JSON-RPC over the MCP endpoint) with a compact summary of the
LiteLLM request — model, call type, message count, temperature, stream
flag, plus the last user message so the audit trail carries context.
Guard returns one of five verdicts:
| Verdict | LiteLLM behaviour |
|---|---|
ok / allow |
Request forwarded to the upstream model. |
advisory |
Forwarded, metadata.conduct_guard annotated. |
WARNING |
Forwarded, warning surfaced in metadata. |
BLOCKED |
LiteLLM returns an error to the caller. No upstream token spent. |
PENDING approval |
Blocked pending HITL. Caller receives an error citing the rule. |
Configuration reference
| Field | Required | Default | Notes |
|---|---|---|---|
api_url |
no | https://gateway.conductai.ai |
Point at a self-hosted Conduct API when needed. |
agent_token |
yes | CONDUCT_AGENT_TOKEN env |
cond_agt_* token minted in the Conduct console. |
workspace_id |
no | resolved from the token | Usually unnecessary — the token owns its workspace. |
unreachable_fallback |
no | fail_closed |
fail_closed blocks when Guard is unreachable, fail_open allows. Renamed from fail_mode in v0.2.5 — the old name still works with a DeprecationWarning and is removed in v0.3.0. |
timeout |
no | 8.0 |
Seconds. Guard checks return in <100ms in the healthy path. |
Session tracking
Guard uses a session ID to correlate the pre-call check with any resume-verdict / HITL approval that follows. The adapter picks the first value it finds in this order:
litellm_metadata.trace_idmetadata.X-Conduct-Session-Id(explicit override — set this if you want deterministic control over the session boundary).metadata.conduct_session_id.- A deterministic hash of the
userfield plus the first user message.
If none of the above are available and the caller sends no user or
messages, session tracking is skipped (single-shot mode). Approvals
still work — they just can't be resumed against a prior check.
Fail modes
fail_closed(default) — blocks the call if Guard is unreachable or the policy evaluator errors. Matches Conduct's default posture across every other enforcement surface.fail_open— allows the call and logs a warning. Use during rollout or if Guard is a soft dependency for your setup.
License
conduct-litellm-guard is distributed under the
Apache License 2.0, the same license as the rest of Conduct.
Links
- Conduct Guard — the policy engine.
- Conduct Router — Conduct's own LLM proxy.
- Source — this package lives
under
packages/conduct-litellm-guard/. - Issues — file bugs and requests against the parent repo.
Metadata
Release files for conduct-litellm-guard 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| conduct_litellm_guard-0.2.6.tar.gz | 21.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| conduct_litellm_guard-0.2.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.0 kB
Release files / conduct_litellm_guard-0.2.6.tar.gz
| Download URL | conduct_litellm_guard-0.2.6.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76aa498dc4f846a0af38646e489a93af7e49a77503d5361d33bcfc903d64b243
|
|
BLAKE2b-256 checksum How to use checksums |
bd68c36017db0e82cc5560a1cdfb9e3a418d607dc8349f0701ea14d18774bbe8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / conduct_litellm_guard-0.2.6-py3-none-any.whl
| Download URL | conduct_litellm_guard-0.2.6-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fb71b90532864aa82e8cc3c188c2849c44734b4f08f28f5d85633f39cdfeb23
|
|
BLAKE2b-256 checksum How to use checksums |
41b0de93401a5093a8687b4a3986888046b461f84ec5e124a93dcc673f20a9eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency log