Skip to main content

TrigGuard Gateway Client

Project description

trigguard (PyPI)

Official Python 3.9+ client for the TrigGuard execution gatewayPOST /execute using only the standard library (urllib).

Install (from PyPI)

pip install trigguard

Editable (monorepo)

cd sdk/python && pip install -e .

Usage

import os
from trigguard import Client

client = Client(
    api_key=os.environ["TG_API_KEY"],
    base_url="http://127.0.0.1:8080",
)
r = client.execute(
    surface="spendCommit",
    signals={"riskScore": 0.9},
    context={"amount": 1000},
)
print(r["decision"], r.get("execution_id"))

OpenAI function guard (tools)

from trigguard import TrigGuardError
from trigguard.openai import authorize_tool, map_tool_call_to_surface

try:
    authorize_tool(
        surface="spendCommit",
        context={"amount": 1000},
        signals={"riskScore": 0.1},
    )
except TrigGuardError as e:
    print("blocked", e, e.body)
  • Auth: Authorization: Bearer <api_key>
  • Errors: TrigGuardError on non-2xx

Build & publish (maintainers)

Run from the repository root (not from sdk/nodescripts/ is at the root).

cd /path/to/TrigGuard
python3 -m pip install build twine
bash scripts/publish-pypi.sh

On macOS, if pip is not found, use python3 -m pip as above. Configure twine (~/.pypirc or env) before upload.

See also

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

trigguard-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trigguard-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file trigguard-0.1.1.tar.gz.

File metadata

  • Download URL: trigguard-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for trigguard-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3db495322d02837aa939a624f1432f64eb8c9edc102bf18fed8461e9185a8d1a
MD5 cdc9862f38a1787a52ac54bdf7158088
BLAKE2b-256 1e23a7fc1575d8b0d42c56fb8867466488c70320357b4f9384799f009a0f86b4

See more details on using hashes here.

File details

Details for the file trigguard-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: trigguard-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for trigguard-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a004cdaa2e4e3e2b867b8d1b52c22c056922868a6ce88b502971fe12975dd84
MD5 18692fb403ab6379718740e69c96b048
BLAKE2b-256 0d37b75f04a36c287a2f0c3c9cf032cbab7d2fbc7f94de99c3a5c9981fd2a295

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page