Documentation Index
Fetch the complete documentation index at: https://docs.truthsystems.ai/llms.txt
Use this file to discover all available pages before exploring further.
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
import asyncio
from gateway import TextSource, Verdict
from gateway.azure import AzureClient
client = AzureClient.from_function_app_url(
"https://yourprefix-func.azurewebsites.net",
api_key="your-function-key",
)
ruling = asyncio.run(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 Azure client is async — use await in async code, or asyncio.run() as shown above.
The judge method:
- Sends the claim and sources to Gateway
- Waits for completion (polls automatically)
- Returns a
Ruling object with the verdict and evidence
Authentication
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)
The AzureClient authenticates with the Function App’s function key, passed directly at construction time:from gateway.azure import AzureClient
client = AzureClient.from_function_app_url(
"https://yourprefix-func.azurewebsites.net",
api_key="your-function-key",
)
The URL and key are available as Terraform outputs after deployment. Retrieve the key with terraform output function_app_default_key.
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:
| Type | Description |
|---|
TextSource | A plain-text source document |
Ruling | The result of client.judge() |
Statement | A single statement extracted from the claim |
Influence | Evidence from a source that influenced a verdict |
TextInfluence | Evidence from a TextSource, includes character spans |
Verdict | Enum: 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}")