Python client for the Inhibitor policy compliance inference API
Project description
Inhibitor Python SDK
Official Python client for the Inhibitor policy compliance API. Evaluate natural-language content against your policies and get ALLOW, MODIFY, or BLOCK decisions with explanations.
Features
- Simple API — Send only
query,metadata, andadditional_metadata; no extra parameters. - Structured metadata — Use the
{"key": {"value": "val", "description": "des"}}shape for clear, documented context. - Sync and async —
InhibitorClientandAsyncInhibitorClientwith the same interface. - Typed models — Pydantic request/response models for IDE support and validation.
Installation
pip install inhibitor
Requirements: Python 3.9+, httpx, pydantic.
Quick start
from inhibitor import InhibitorClient
client = InhibitorClient(api_key="your-api-key")
response = client.inference.query(
"Can I share this document with external partners?",
metadata={
"consent": {"value": "yes", "description": "User gave consent"},
"data_type": {"value": "PHI", "description": "Contains protected health info"},
},
)
print(response.final_decision) # ALLOW | MODIFY | BLOCK
print(response.explanation) # Human-readable explanation
print(response.suggestion) # Suggested rewording (if MODIFY)
print(response.processing_time_seconds)
client = InhibitorClient(api_key="your-api-key", base_url="https://your-custom-api.com")
API overview
What you send (request)
Only three fields are accepted:
| Field | Type | Required | Description |
|---|---|---|---|
| query | str |
Yes | Natural language content to evaluate against your policies. |
| metadata | dict |
No | Context for compliance. Shape: {"key": {"value": "val", "description": "des"}}. Used by the engine for the decision. |
| additional_metadata | dict |
No | Stores optional user information (e.g., name, email) as key-value pairs, saved along with the inference log for auditing purposes. Example: {"user_name": "John Doe", "email": "john.doe@example.com"} |
Metadata shape — Each key maps to an object with:
- value (str): The actual value (e.g.
"yes","PHI"). - description (str): Optional short description of the field.
Example:
metadata = {
"consent": {"value": "yes", "description": "User consent obtained"},
"classification": {"value": "internal", "description": "Document classification"},
}
What you get (response)
InferenceResponse includes:
| Field | Type | Description |
|---|---|---|
query |
str | Echo of the query. |
final_decision |
str | ALLOW, MODIFY, or BLOCK. |
final_score |
float | Aggregate score (0–1). |
matched_policies |
list[str] | Policies that were evaluated. |
model_results |
list[RuleResult] | Per-rule decision, confidence, and probabilities. |
explanation |
str | None | Human-readable explanation. |
make_it_complient |
str | None | Suggested changes for the query. |
Usage
Sync client
from inhibitor import InhibitorClient, InferenceRequest
client = InhibitorClient(api_key="your-api-key")
# Simple query
response = client.inference.query("Should I send this email to a competitor?")
# With metadata (authoritative context for the engine)
response = client.inference.query(
"Share the report with the client.",
metadata={
"consent": {"value": "yes", "description": "Client consent on file"},
"channel": {"value": "email", "description": "Delivery channel"},
},
)
# With additional_metadata (stored with log only)
response = client.inference.query(
"Upload to cloud storage.",
additional_metadata={"user_name": "John Doe", "email": "john.doe@example.com"},
)
# Using the request model
req = InferenceRequest(
query="Can I export this data?",
metadata={"data_type": {"value": "PII", "description": "Personal data"}},
)
response = client.inference.run(req)
Async client
from inhibitor import AsyncInhibitorClient
async with AsyncInhibitorClient(api_key="your-api-key") as client:
response = await client.inference.query_async(
"Can I share this document?",
metadata={"consent": {"value": "yes", "description": "Consent given"}},
)
print(response.final_decision)
# Or with run_async
req = InferenceRequest(query="...", metadata={...})
response = await client.inference.run_async(req)
Configuration
| Parameter | Description |
|---|---|
api_key |
Required. Your Inhibitor API key (from the dashboard). |
base_url |
Override API base URL. Default: https://inhibitor-be.envistudios.com. |
timeout |
Request timeout in seconds (default: 60.0). |
headers |
Optional extra HTTP headers. |
The client sends the API key in the X-API-Key header. No other auth is required.
Exceptions
| Exception | When |
|---|---|
| InhibitorAuthError | Invalid or expired API key (401). |
| InhibitorValidationError | Bad request or invalid parameters (400). |
| InhibitorAPIError | Other API errors (4xx/5xx). Has status_code, detail, response_body. |
All extend InhibitorError (with message and optional status_code).
from inhibitor import InhibitorClient
from inhibitor.exceptions import InhibitorAuthError, InhibitorAPIError
client = InhibitorClient(api_key="your-api-key")
try:
r = client.inference.query("Some query")
except InhibitorAuthError as e:
print("Auth failed:", e.message)
except InhibitorAPIError as e:
print("API error:", e.status_code, e.detail)
Integration checklist
- Get an API key from your Inhibitor dashboard.
- Install —
pip install inhibitor. - Create client —
InhibitorClient(api_key="..."). - Call —
client.inference.query(query, metadata=..., additional_metadata=...). - Handle — Use
response.final_decision,response.explanation, and catchInhibitorAuthError/InhibitorAPIErroras needed.
Package structure
Each module has a single responsibility:
| Module | Purpose |
|---|---|
inhibitor.constants |
Default base URL and API path. |
inhibitor._http |
HTTP response helpers (e.g. error detail extraction). |
inhibitor.models |
Request/response Pydantic models and metadata shape. |
inhibitor.inference |
Inference API (sync/async): query, run, query_async, run_async. |
inhibitor.client |
Sync and async HTTP clients. |
inhibitor.exceptions |
Auth, validation, and API exceptions. |
Import the public API from inhibitor; use submodules only if you need constants or helpers.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inhibitor-0.1.2.tar.gz.
File metadata
- Download URL: inhibitor-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98f706e3b00329de760338b1eaf8dcf221ca9f91cd2148b1e7f8141c6874241c
|
|
| MD5 |
7ad03ed0c977db6c073ef447186ee544
|
|
| BLAKE2b-256 |
1efc097e15cf2c77e716a9206da2939c954dcdea6320a1a67f73082b30aa302f
|
File details
Details for the file inhibitor-0.1.2-py3-none-any.whl.
File metadata
- Download URL: inhibitor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5e9d93db17247f042668e32b2b3b3313307f4eefc653182636f05a5baf79b6e
|
|
| MD5 |
e27e39029b3abbdef3cddc0b61547d2b
|
|
| BLAKE2b-256 |
e0d399b61ab6f3d92d7dbb4a027b7f5f80dc059c8fb4278b5708eac6be1683f0
|