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
          fail_mode: 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
          fail_mode: 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.
fail_mode no fail_closed fail_closed blocks when Guard is unreachable, fail_open allows.
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.

  • 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.2

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.2
File Size Uploaded
conduct_litellm_guard-0.2.2.tar.gz 20.0 kB Details

Built distribution (wheel)

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

Total release size: 36.2 kB

Release files / conduct_litellm_guard-0.2.2.tar.gz

Download URL conduct_litellm_guard-0.2.2.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e1b9f1bceb8d4f066134646f30b1f29086103f93a084ae9782926589fd761dec
BLAKE2b-256 checksum
How to use checksums
9dfcadd5014e371c5481613c559d0782c476d44928f79c72c3738caa3f6b2f5a
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 11, 2026.

Transparency log

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

Download URL conduct_litellm_guard-0.2.2-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13829c0864bfe62f943464be039f9029b34acc065f7de3ee72788f6729a75f8d
BLAKE2b-256 checksum
How to use checksums
a78380ebbec07c6fc3ba4e7f29cc75b2bf795b22022ec7fd760a9fb112a35c01
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 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

This release

0.2.2 This release

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