Docs / SDK
Developers · Integration

SDK · Python · TypeScript

IN-PROCESS ENFORCEMENT · SAME CHECKPOINT, NO EXTRA HOP

When you'd rather enforce inside your own agent loop, the SANSAR SDK wraps each tool call in code.

You get the same checkpoint as the gateway — policy, identity, signed stamp — without a separate network hop. Wrap the tools your agent can reach, and every invocation returns a verdict plus a verifiable evidence record.

Install

Python

# Python 3.9+
pip install sansar

TypeScript / Node

// Node 18+
npm install @sansar/sdk

Wrap a tool call

Python

from sansar import Gate

gate = Gate(agent="billing-bot", key=SANSAR_KEY)

# check before you act
verdict = gate.check(action="refund", args={"amount": 240, "acct": "A-19"})

if verdict.allowed:
    result = tools.refund(amount=240, acct="A-19")
    gate.stamp(verdict, result)   # signed evidence record
else:
    escalate(verdict.reason)      # blocked or sent to a human

TypeScript

import { Gate } from "@sansar/sdk";

const gate = new Gate({ agent: "billing-bot", key: SANSAR_KEY });

const verdict = await gate.check({ action: "refund", args: { amount: 240, acct: "A-19" } });

if (verdict.allowed) {
  const result = await tools.refund({ amount: 240, acct: "A-19" });
  await gate.stamp(verdict, result);   // signed evidence record
} else {
  escalate(verdict.reason);
}

What you get back

The snippets above are illustrative. The current SDK, endpoints, and signing keys are provided during onboarding — email info@sansarai.ai or explore the live demo. Prefer a drop-in proxy with no code changes? See the MCP Gateway.