Gateplex Python SDK — real-time AI governance firewall
Project description
Gateplex Python SDK
Real-time AI governance firewall for LLM applications. Drop-in intercept logging, PII detection, spend controls, and human-in-the-loop approval workflows — deployable inside your VPC.
Installation
pip install gateplex-python
Quick start
from gateplex import GateplexClient
client = GateplexClient(api_key="gp-...")
response = client.log_intercept(
agent_id="<your-agent-uuid>",
event_type="llm_call",
input="Summarise the patient record for John Smith",
output="John Smith, DOB 1982-03-14, diagnosis: ...",
)
if response.is_blocked:
raise RuntimeError("Request blocked by governance policy")
print(response.verdict, response.pii_types_detected)
Verdict values
| Verdict | Meaning |
|---|---|
ALLOW |
Request passed all rules |
FLAG |
Request flagged for audit; execution continues |
BLOCK |
Request blocked; raise GateplexBlockedError |
PENDING_APPROVAL |
Awaiting human reviewer approval |
log_intercept automatically raises GateplexBlockedError on a BLOCK verdict.
Human-in-the-loop approvals
from gateplex import GateplexClient, GateplexRejectedError
client = GateplexClient(api_key="gp-...")
try:
response = client.log_intercept(
agent_id="<agent-uuid>",
event_type="llm_call",
input=user_prompt,
output=llm_output,
wait_for_approval=True, # blocks until reviewer acts
poll_timeout=600, # seconds (default 300)
)
except GateplexRejectedError as e:
print("Reviewer rejected the request:", e)
You can also poll manually:
response = client.log_intercept(...)
if response.is_pending_approval:
approval = client.wait_for_approval(response.intercept_id)
print(approval.status, approval.reviewer_note)
InterceptResponse fields (v0.2.3)
response.intercept_id # str
response.verdict # "ALLOW" | "FLAG" | "BLOCK" | "PENDING_APPROVAL"
response.reasoning # str — human-readable explanation
response.triggered_rules # List[str] — rule IDs/names that fired
response.pii_types_detected # List[str] — e.g. ["EMAIL", "SSN"]
response.transaction_amount # Optional[float]
response.requires_approval # bool
# Convenience properties
response.is_allowed
response.is_flagged
response.is_blocked
response.is_pending_approval
ApprovalStatus fields (v0.2.3)
approval.intercept_id # str
approval.status # "PENDING" | "APPROVED" | "REJECTED"
approval.reviewed_by # Optional[str]
approval.reviewed_at # Optional[str] — ISO 8601
approval.reviewer_note # Optional[str]
approval.is_approved
approval.is_rejected
approval.is_pending
Background batch logging
# Fire-and-forget — does not block the hot path
client.batch_intercept(
agent_id="<agent-uuid>",
event_type="llm_call",
input=prompt,
output=completion,
)
# Drain the queue before process exit
client.flush()
LLM library integrations
from gateplex.integrations import OpenAIPatcher, AnthropicPatcher
import openai
openai_client = openai.OpenAI(api_key="sk-...")
patcher = OpenAIPatcher(client, agent_id="<agent-uuid>", openai_client=openai_client)
patcher.patch()
# All openai_client.chat.completions.create calls are now logged automatically
patcher.unpatch()
@monitor decorator
from gateplex.integrations import monitor
@monitor(client, agent_id="<agent-uuid>", event_type="llm_call")
def call_llm(input: str) -> str:
return my_llm(input)
Exceptions
| Exception | When raised |
|---|---|
GateplexAuthError |
Invalid or missing API key |
GateplexAPIError |
HTTP error from the Gateplex API |
GateplexValidationError |
Malformed request payload |
GateplexBlockedError |
Verdict is BLOCK |
GateplexRejectedError |
Human reviewer rejected a PENDING_APPROVAL intercept |
Context manager
with GateplexClient(api_key="gp-...") as client:
client.log_intercept(...)
Changelog
0.2.3
InterceptResponsegainsverdict,reasoning,triggered_rules,pii_types_detected,transaction_amount,requires_approval, andis_*convenience properties.- New
ApprovalStatusdataclass. GateplexClient.wait_for_approval()— polls until approval resolves.log_interceptgainswait_for_approvalparameter.- New
GateplexBlockedErrorandGateplexRejectedErrorexceptions. Guardrailgainsrequires_approvalfield.
0.2.2
@monitordecorator andOpenAIPatcher/AnthropicPatcherintegrations.
0.2.1
- Initial public release.
Project details
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 gateplex_python-0.2.3.tar.gz.
File metadata
- Download URL: gateplex_python-0.2.3.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d76d9bbce38379d31bfe8d5054b4b33f91b398b90f87a35cb20f4f6ae23340b5
|
|
| MD5 |
ce9e40befc606c692fd68b0958235773
|
|
| BLAKE2b-256 |
3517f6bb12b4d5de4dcd775bfb4a156da4b9720cfd2b2c081bb315b6dc31b5c5
|
File details
Details for the file gateplex_python-0.2.3-py3-none-any.whl.
File metadata
- Download URL: gateplex_python-0.2.3-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24784e2f1a1796de73df36ec7687e8db8cfe11a39988b27b9bb1ee1a252c7552
|
|
| MD5 |
ff18f6833307448506667be84e439420
|
|
| BLAKE2b-256 |
52153cd1f0eacaf8ff18957e568167e0dc15c3e88e4aa0a5d02c3654b3afde60
|