Skip to main content
Deploy the integrations/arthur-ai FastAPI wrapper on any public HTTPS host. The gateway calls it at llm_input / llm_output via the Custom Guardrail contract; the wrapper forwards traffic to Arthur GenAI Engine and returns verdict JSON on HTTP 200.

What is Arthur AI?

Arthur GenAI Engine is a SaaS platform for validating LLM prompts and completions. The wrapper calls POST /api/v2/validate and maps rule results to pass/block — it does not embed policy logic beyond the checks you configure. Arthur is validate-only. Use Operation: Validate for both input and output rails. It reports failures but does not redact or rewrite text. Default checks when config is {}:
  • Input: PromptInjectionRule + ToxicityRule
  • Output: ToxicityRule

How it works

  1. The gateway POSTs an OpenAI-shaped requestBody (input) or requestBody + responseBody (output) to your wrapper URL.
  2. The wrapper extracts user/assistant text and calls Arthur with your ARTHUR_API_KEY.
  3. The wrapper returns HTTP 200 with a policy outcome in the body. Infrastructure failures return HTTP 5xx.
TF customer's app ─► TF gateway ─► this wrapper ─► engine.platform.arthur.ai/api/v2/validate

Response contract

HTTPBodyMeaning
200{"verdict": true}Allow
200{"verdict": false, "message": "..."}Block (policy)
5xxerror JSONWrapper or Arthur failure
Policy blocks use 2xx + verdict: false, not HTTP 4xx. See Custom guardrail response contract.

Wrapper endpoints

PathTarget
/validate-inputRequest (input)
/validate-outputResponse (output)
GET /health — health check. GET /debug/loaded-config — bearer-gated diagnostics. All POST routes expect Authorization: Bearer <WRAPPER_API_KEY>.

Prerequisites

  • Arthur API key from the Arthur platform.
  • Public HTTPS URL for the deployed wrapper.
  • WRAPPER_API_KEY — shared secret the gateway sends as Authorization: Bearer ….

Setup

1

Clone and configure

git clone https://github.com/truefoundry/integrations-custom-guardrails
cd integrations-custom-guardrails/integrations/arthur-ai
cp .env.example .env
.env
ARTHUR_API_KEY=<from https://platform.arthur.ai>
WRAPPER_API_KEY=<generate: python -c "import secrets; print(secrets.token_urlsafe(32))">
2

Deploy the wrapper

TrueFoundry:
pip install -U truefoundry
tfy login
python deploy.py --wait
Set TFY_WORKSPACE_FQN, TFY_PUBLIC_HOST, TFY_PUBLIC_PATH, and secret FQNs in .env. Create secrets arthur-api-key and wrapper-api-key under group arthur-guardrails-tfy in Platform → Secrets.Local:
python3 -m venv .venv
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/uvicorn main:app --reload --port 8000
3

Register Custom Guardrail configs

AI Gateway → Guardrails → + Add New Guardrails Group → type Custom.
  • Group name: arthur-ai
  • Add two configs — input and output.
Input validate example:
FieldValue
Namearthur-input-validate
OperationValidate
TargetRequest
Enforcing StrategyEnforce But Ignore On Error
URLhttps://<host>/validate-input
HeadersAuthorizationBearer <WRAPPER_API_KEY>; Content-Typeapplication/json
Config{}
TrueFoundry custom guardrail form: Validate, Request target, /validate-input URL, Authorization Bearer header
Output validate:
FieldValue
Namearthur-output-validate
OperationValidate
TargetResponse
URLhttps://<host>/validate-output
Auth Data → Custom Bearer Auth works the same as Headers if you prefer not to set headers manually.
4

Attach to traffic

Model pin: AI Gateway → Models → <model> → Guardrails → attach group arthur-ai.Per requestX-TFY-GUARDRAILS header, selector format <group>/<config-name>:
{
  "llm_input_guardrails": ["arthur-ai/arthur-input-validate"],
  "llm_output_guardrails": ["arthur-ai/arthur-output-validate"]
}

Custom config (optional)

Override defaults by setting config.checks in the dashboard:
{
  "checks": [
    {"name": "prompt-injection-check", "type": "PromptInjectionRule", "apply_to_prompt": true, "apply_to_response": false},
    {"name": "toxicity-check", "type": "ToxicityRule", "apply_to_prompt": true, "apply_to_response": false, "config": {"threshold": 0.5}}
  ],
  "fail_closed_on_unavailable": false
}
KeyPurpose
credentials.apiKeyOverride ARTHUR_API_KEY env var
api_baseOverride Arthur API host (default https://engine.platform.arthur.ai)
timeoutRequest timeout in seconds (default 30)
context / grounding_contextGrounding text for hallucination checks
fail_closed_on_unavailableBlock when Arthur returns Skipped/Unavailable (default false)

Troubleshooting

SymptomLikely cause
401 from wrapperWRAPPER_API_KEY on the service does not match the dashboard Bearer token
Gateway allows despite verdict: falseTenant gateway not honoring verdict-on-200; set Enforce or upgrade gateway
Arthur Skipped/Unavailable but traffic allowedDefault behavior; set fail_closed_on_unavailable: true in config
Wrong checks runningCurl /debug/loaded-config with Bearer auth to inspect loaded config

Reference

ItemValue
Source repotruefoundry/integrations-custom-guardrails/integrations/arthur-ai
Arthur platformplatform.arthur.ai
Arthur APIPOST https://engine.platform.arthur.ai/api/v2/validate
Selectorarthur-ai/<config-name>