Skip to main content

capsule-litellm

Capsule plugin for the LiteLLM LLM gateway. Forwards completion/chat requests to the Capsule agentsecurity service for centralized policy enforcement (pre-call allow/deny) and token/latency audit (post-call telemetry).

Install

pip install capsule-litellm

Install it into the same environment that runs your LiteLLM proxy.

Configure

Register the callback in your LiteLLM config.yaml:

litellm_settings:
  callbacks: ['capsule_litellm_plugin.capsule_callback']

The callback reads its configuration from environment variables. Set these where the LiteLLM proxy runs:

export CAPSULE_LITELLM_ENDPOINT="https://agents.capsule.security/v1/litellm/hooks"
export CAPSULE_LITELLM_TOKEN="<token from the Capsule portal>"

The endpoint and token values are issued by Capsule when you install the LiteLLM integration in the portal (Integrations → LiteLLM). The token is a JWT scoped to your tenant and environment — treat it as a secret.

Optional environment variables

Variable Default Description
CAPSULE_LITELLM_BLOCK_ON_RISK true Apply server deny verdicts inline. Set to false to run the plugin in observe-only mode.
CAPSULE_LITELLM_FAIL_OPEN true Allow the request through if Capsule is unreachable or returns a non-2xx response. Set to false to fail closed.
CAPSULE_LITELLM_TIMEOUT_MS 5000 Per-request HTTP timeout in milliseconds.

How it works

Hook Type Description
async_pre_call_hook Blocking Posts the model + messages to events/pre and awaits an allow/deny verdict before the upstream call.
async_log_success_event Observation Posts model, latency, and token usage to events/post after a successful completion.
async_log_failure_event Observation Posts model, latency, and the error to events/post when the upstream call fails.

When block_on_risk is enabled and Capsule returns decision: "deny", the pre-call hook raises a 403 so LiteLLM rejects the request before it reaches the upstream provider.

License

Capsule Security Commercial License. See LICENSE.

Metadata

Release files for capsule-litellm 0.1.0

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

Source distribution (sdist)

Source distribution for capsule-litellm 0.1.0
File Size Uploaded Provenance
capsule_litellm-0.1.0.tar.gz 6.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for capsule-litellm 0.1.0
File Interpreter ABI Platform
capsule_litellm-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / capsule_litellm-0.1.0.tar.gz

Download URL capsule_litellm-0.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dbfc5161ab470309f49ccaf523b79efe4db25b0be49c287234488045f196c995
BLAKE2b-256 checksum
How to use checksums
2f149a946d8ba19a193a6577e0803790b476c9f64e199dd0be6a8168345e886c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / capsule_litellm-0.1.0-py3-none-any.whl

Download URL capsule_litellm-0.1.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5754641ad361ad4de7a229bb71748a12d2df656b97135a948d6dc2a0422eefc5
BLAKE2b-256 checksum
How to use checksums
7b96ef5c74b4cc2a9048506f5a771766be8359b3bfb6b546af8faf24621d9a31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for capsule-litellm 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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