Skip to main content

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

  1. Mint an agent token in the Conduct console (Settings → Agent identities). Copy the cond_agt_… value.

  2. Export it in the environment where your LiteLLM proxy runs:

    export CONDUCT_AGENT_TOKEN=cond_agt_...
    
  3. Add the guardrail to your LiteLLM proxy's config.yaml. Two forms — both work today, they differ only in the guardrail: 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://api.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_key parameter 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.

  4. 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://api.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:

  1. litellm_metadata.trace_id
  2. metadata.X-Conduct-Session-Id (explicit override — set this if you want deterministic control over the session boundary).
  3. metadata.conduct_session_id.
  4. A deterministic hash of the user field 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.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conduct-litellm-guard 0.2.5
File Size Uploaded
conduct_litellm_guard-0.2.5.tar.gz 21.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conduct-litellm-guard 0.2.5
File Interpreter ABI Platform
conduct_litellm_guard-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 39.0 kB

Release files / conduct_litellm_guard-0.2.5.tar.gz

Download URL conduct_litellm_guard-0.2.5.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
46f3c8e9e0801b1d08fe3d10e11c04399d7a5506a9c1512c9cc9d7d5262b9eb6
BLAKE2b-256 checksum
How to use checksums
b6d6ba9de522ede3b9802561f4dd3aa2ad43c7f761e8bb89f30f4003fea31b8a
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 12, 2026.

Transparency log

Release files / conduct_litellm_guard-0.2.5-py3-none-any.whl

Download URL conduct_litellm_guard-0.2.5-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4435eef09d710dac219fd0b1cc633973b357230d00b1c884365119fbaeb8d713
BLAKE2b-256 checksum
How to use checksums
b69508d71015eb5eaf6adcb45637bce3d5d86579f76e287ad827a2988643ebb7
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 12, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.7

2 release files

0.2.6

2 release files

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page