Skip to main content
The examples below use AWS. Azure support is coming soon with a similar API.

Basic usage

from gateway import TextSource, Verdict
from gateway.aws import AwsClient

client = AwsClient.from_sfn_arn("arn:aws:states:us-east-1:123456789:stateMachine:gateway")

ruling = client.judge(
    claim="Sally is a cat",
    sources=[
        TextSource(id="pet-info", text="I have a cat called Sally."),
        TextSource(id="pet-count", text="I only have one pet."),
    ],
)

print(ruling.verdict)  # Verdict.SUPPORTS
The judge method:
  1. Sends the claim and sources to Gateway
  2. Waits for completion (polls automatically)
  3. Returns a Ruling object with the verdict and evidence

Authentication (AWS)

The AwsClient uses your AWS credentials to invoke the Step Function. Credentials are loaded automatically from:
  • Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
  • IAM role (when running on AWS)
  • AWS credentials file (~/.aws/credentials)
To use a specific profile or region:
import boto3
from gateway.aws import AwsClient

session = boto3.Session(profile_name="my-profile")
client = AwsClient.from_sfn_arn("arn:aws:states:...", session=session)

Sources

Currently, only text sources are supported:
from gateway import TextSource

# With explicit ID (recommended for tracing evidence)
source = TextSource(id="doc-123", text="The sky is blue.")

# Auto-generated ID
source = TextSource.from_text("The sky is blue.")

Types

All types are importable from gateway:
TypeDescription
TextSourceA plain-text source document
RulingThe result of client.judge()
StatementA single statement extracted from the claim
InfluenceEvidence from a source that influenced a verdict
TextInfluenceEvidence from a TextSource, includes character spans
VerdictEnum: SUPPORTS, REFUTES, NOT_ENOUGH_INFO

Errors

Errors are raised from gateway.errors:
from gateway.errors import APIError

try:
    ruling = client.judge(claim="...", sources=[...])
except APIError as e:
    print(f"Gateway error: {e}")