tripwire-litellm
Per-client budget hard stop and cost logging for a LiteLLM proxy. Before each call through your LiteLLM proxy, the plugin checks that client's budget in Tripwire and denies the call with HTTP 402 once the budget is used up. After each call, it logs the cost to Tripwire per client and project, so you can see what each client actually costs you.
Built for AI agencies that run client work through one shared LiteLLM proxy and need to know, and cap, what each client spends.
You need a Tripwire account. There's a free 14-day trial, no card required, at https://www.tripwire.agency. The hard stop applies on the Agency and Scale plans and during an active trial. On Starter (or an expired trial) calls are always allowed and cost is still logged.
Walkthrough video: https://www.youtube.com/watch?v=d6WsQY1OMD4
Install
Python 3.9 or newer, on the machine that runs your LiteLLM proxy (LiteLLM proxy 1.65.0 or newer).
pip install tripwire-litellm
Config
Point callbacks at the handler instance in your proxy config:
litellm_settings:
callbacks: ["tripwire_litellm.handler.proxy_handler_instance"]
Then set the environment variables (defaults shown):
TRIPWIRE_INGEST_TOKEN=tw_live_... # required, never log it
TRIPWIRE_BASE_URL=https://www.tripwire.agency
TRIPWIRE_FAIL_MODE=open # or closed
TRIPWIRE_CHECK_TIMEOUT_MS=800
TRIPWIRE_DENY_STATUS=402 # not 429; SDKs retry 429
TRIPWIRE_RESERVE_USD=0
TRIPWIRE_HARD_STOP=on # off = ingest only
TRIPWIRE_CLIENT_ID=
TRIPWIRE_PROJECT_ID=
Calls are attributed to a client and project from, in order: request metadata (tripwire_client_id, tripwire_project_id), the virtual key's metadata, the team's metadata, then TRIPWIRE_CLIENT_ID / TRIPWIRE_PROJECT_ID.
Limits
- Fail-open by default. If Tripwire can't be reached (timeout, network error, 5xx, 401), the call is allowed. Set
TRIPWIRE_FAIL_MODE=closedto return 503 instead. After 5 failures in a row, checks are skipped for 30 seconds. - Spend is known after the call. Tripwire learns the cost when a call finishes and is ingested, so calls already running when the budget is crossed still complete. Worst-case overshoot is about 2 × concurrency × average call cost, and never less than your single largest call.
- Fixed reserve.
TRIPWIRE_RESERVE_USDsends the same estimated cost with every check. There is no per-request sizing from tokens. Lower concurrency on a key, a reserve, or fail-closed mode reduce overshoot.
For developers
Hooks (checked against the LiteLLM proxy call-hook docs, 2026-10-05):
async_pre_call_hook(self, user_api_key_dict, cache, data, call_type): returnsdataunchanged on allow; on deny raisesfastapi.HTTPException402 witherror.codetripwire_budget_exceeded.async_log_success_event(self, kwargs, response_obj, start_time, end_time): call id fromkwargs["litellm_call_id"], thenkwargs["litellm_params"]["litellm_call_id"], thenresponse_obj.id; cost and provider fromkwargs["response_cost"],kwargs["litellm_params"]["custom_llm_provider"],kwargs["model"].
Unit tests stub litellm.integrations.custom_logger when LiteLLM isn't installed.
Metadata
Release files for tripwire-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 | Actions |
|---|---|---|---|---|
| tripwire_litellm-0.1.1.tar.gz | 10.9 kB | Without provenance | Details for tripwire_litellm-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tripwire_litellm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for tripwire_litellm-0.1.1-py3-none-any.whl |
Total release size: 18.3 kB
Release files / tripwire_litellm-0.1.1.tar.gz
| Download URL | tripwire_litellm-0.1.1.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7ab06b77aa3c085de2c75fb7e8f9a916e84c0a171e34355c2d17d09113c6376
|
|
BLAKE2b-256 checksum How to use checksums |
4ffbf5212777f76ffe595972e92ab64ae10eb99a22e6eb7b7fb7153a6ec29510
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / tripwire_litellm-0.1.1-py3-none-any.whl
| Download URL | tripwire_litellm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
665695c51c8dff13860d75fd832f0bd0ed4c48c8adb66567836058c80974395a
|
|
BLAKE2b-256 checksum How to use checksums |
96ef40455f2faff7402026687005aec563e398616aac818a3e4c97fb817d8e02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for tripwire-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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.