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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| capsule_litellm-0.1.1.tar.gz | 7.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| capsule_litellm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.6 kB
Release files / capsule_litellm-0.1.1.tar.gz
| Download URL | capsule_litellm-0.1.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbbe65effd8c2d23c7db292d1b9900ecba193e4b8596f88198a39718075f89dd
|
|
BLAKE2b-256 checksum How to use checksums |
a9ff55d86a075faa9dfc76305a645e757822889a32777c06e6439d71337cda07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / capsule_litellm-0.1.1-py3-none-any.whl
| Download URL | capsule_litellm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
665ca298dbb1a157bb799d5f36a82ea34c2425548f18533218adb4629c11dfe5
|
|
BLAKE2b-256 checksum How to use checksums |
1824e7b97264fcc0d7b8ccd5e446adc86eb825acfaeda11dff9467d937015942
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for capsule-litellm 0.1.1
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.