Metadata-Version: 2.5
Name: trigguard-litellm
Version: 0.1.1
Summary: LiteLLM ↔ TrigGuard policy gate — four-state authorize before routing
Project-URL: Homepage, https://www.trigguardai.com
Project-URL: Repository, https://github.com/TrigGuard-AI/TrigGuard
Project-URL: Documentation, https://trigguardai.com/docs
Project-URL: Issues, https://github.com/TrigGuard-AI/TrigGuard/issues
Author-email: TrigGuard AI <opensource@trigguardai.com>
License-Expression: MIT
License-File: LICENSE
Keywords: authorization,governance,litellm,llm,trigguard
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: litellm>=1.0.0; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Provides-Extra: litellm
Requires-Dist: litellm>=1.0.0; extra == 'litellm'
Description-Content-Type: text/markdown

# trigguard-litellm

LiteLLM callback that gates every model call through TrigGuard `POST /execute`.

LiteLLM can only halt a call by raising. Those raises are **control flow**, not a binary error model.

| Gateway | Meaning | Callback |
|---------|---------|----------|
| **PERMIT** | Authorized; caller may execute | return (continue) |
| **DENY** | Explicitly do not execute (terminal) | `TrigGuardDenied` |
| **ESCALATE** | Do not execute *yet*; approval required | `TrigGuardEscalationRequired` |
| **SILENCE** | No actionable authorization | `TrigGuardNoDecision` (fail closed, not a denial) |

`ESCALATE ≠ DENY`. `SILENCE ≠ DENY`. `SILENCE ≠ PERMIT`. `OBSERVE` does not proceed.

## Install

```bash
pip install trigguard-litellm
# optional: pip install 'trigguard-litellm[litellm]'
```

## Usage

```python
import litellm
from trigguard_litellm import TrigGuardLiteLLMCallback

litellm.callbacks = [
    TrigGuardLiteLLMCallback(
        gateway_url="https://api.trigguardai.com",
        api_key="tg_live_...",
    )
]
```

Constructor arguments default to `TRIGGUARD_GATEWAY_URL` and `TRIGGUARD_API_KEY`.

Imperative gate (no LiteLLM required):

```python
from trigguard_litellm import TrigGuardPolicyGate

gate = TrigGuardPolicyGate(
    gateway_url="https://api.trigguardai.com",
    api_key="tg_live_...",
)
result = gate.authorize(context={"model": "gpt-4o"})
```

## Related

- `@trigguard/execution-sdk` — Node client for the same `/execute` rail
- `trigguard` on PyPI — Python SDK (`authorize` / `verify`)
