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.1.1

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.1.1
File Size Uploaded
conduct_litellm_guard-0.1.1.tar.gz 17.6 kB Details

Built distribution (wheel)

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

Total release size: 32.6 kB

Release files / conduct_litellm_guard-0.1.1.tar.gz

Download URL conduct_litellm_guard-0.1.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d0c7526da19165eb6428b32e72126fe319f9b624110baa4cdb64318e220cc0f5
BLAKE2b-256 checksum
How to use checksums
3126f2ef7bbb59578b371b50aded1a82b3151fab35d7350810fc4e46fd128550
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 5, 2026.

Transparency log

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

Download URL conduct_litellm_guard-0.1.1-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84ff9369c054b78306a7464b9d3a3be0ceaf608a8ca066417b951169749ff96f
BLAKE2b-256 checksum
How to use checksums
3e015079e04b8b242fe0c80bed8eea367ab04f54fded180beb888b7200aa9c99
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 5, 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

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

This release

0.1.1 This release

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