SDKs
Python and TypeScript. Same API as the quickstart.
Download: guardrail.py · guardrail.ts
Python
guardrail = Guardrail(api_key="rg_...", base_url="https://railguardsecurity.com", timeout=15)
payment = guardrail.spend(amount=45, merchant="OpenAI API", category="AI & Compute",
reasoning="…", wait=True, wait_timeout=3600, poll_interval=5)
guardrail.report_receipt(payment["transaction_id"], amount=45, merchant="OpenAI API")TypeScript
const guardrail = new Guardrail({ apiKey: "rg_...", baseUrl: "https://railguardsecurity.com" });
const payment = await guardrail.spend({ amount: 45, merchant: "OpenAI API", category: "AI & Compute", reasoning: "…" });
await guardrail.reportReceipt(payment.transaction_id, { amount: 45, merchant: "OpenAI API" });Behaviour
- Approved → returns status + payment credential.
- Blocked / rejected → throws
SpendBlockedwithreasonandcode. Tell the agent to stop or pick an alternative. - Flagged → with
waiton, the call blocks the tool, polling until a human decides orwait_timeout(thenSpendPending). Withwaitoff, passwebhook_urland resume later. - timeout is the per-HTTP-call timeout (15s default).
log_payment()records a payment the agent already made (log-only).