guides

Getting Started with the Faultr API

F
Faultr Team
March 3, 202610 min read

To begin testing your AI agents for payment compliance, you'll need an active Faultr account and an API key.

Installation#

The easiest way to interact with Faultr is through our official Python SDK.

bash
pip install faultr-sdk

Basic Usage#

The core of Faultr is the

text
Scenario
. A scenario represents a specific adversarial condition your agent must navigate correctly to pass compliance.

1. Initialize the Client#

python
from faultr import Faultr

client = Faultr(api_key="your_api_key_here")

2. Create an Evaluation#

You can run evaluations against a specific agent endpoint or provide a local function that handles agent logic.

python
# Evaluate an agent endpoint
evaluation = client.evaluations.create(
    agent_url="https://api.your-agent.com/v1/chat",
    protocol="AP2",
    categories=["pricing", "unauthorized-disclosure"],
    scenarios=10
)

# Wait for completion
results = evaluation.wait_for_completion()

3. Parsing Results#

Each evaluation returns a detailed breakdown of failures and a compliance score.

python
print(f"Compliance Score: {results.score}%")

for failure in results.failures:
    print(f"Scenario: {failure.scenario_id}")
    print(f"Category: {failure.category}")
    print(f"Reason: {failure.reason}")
Best Practice

Integrate Faultr into your CI/CD pipeline to catch regression errors before they affect live transactions.

Next Steps#

Check our API Reference for advanced configuration options and batch testing support.

Share