> ## 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.

# Usage

> Fact-check claims against sources.

## Basic usage

<Tabs>
  <Tab title="AWS">
    ```python theme={null}
    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
    ```
  </Tab>

  <Tab title="Azure">
    ```python theme={null}
    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.
  </Tab>
</Tabs>

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

<Tabs>
  <Tab title="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:

    ```python theme={null}
    import boto3
    from gateway.aws import AwsClient

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

  <Tab title="Azure">
    The `AzureClient` authenticates with the Function App's function key, passed directly at construction time:

    ```python theme={null}
    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](/deployment/azure). Retrieve the key with `terraform output function_app_default_key`.
  </Tab>
</Tabs>

## Sources

Currently, only text sources are supported:

```python theme={null}
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`:

```python theme={null}
from gateway.errors import APIError

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