Python Usage

Basic Usage

Here's how to use the ts-guard Python SDK:

from ts_guard import Guard

guard = Guard(api_key="your-api-key")

response = guard.validate("Hello, world!")

if not response.is_valid:
    print("Blocked:", response.reasons)
else:
    print("Safe")

Each result contains:

  • blocked: boolean
  • reasons: list of triggered scanners
  • confidence: float value

You can also load settings from YAML:

guard = Guard.from_yaml(".ts-guard.yaml")

Next