Connect your agent · 3 steps

  1. 01 Create a key on API & Keys (shown once).
  2. 02 Wrap every risky tool call in guard() using the code below.
  3. 03 Run the live ping test — results appear in your feed on API & Keys.

Install the Encased package

Python + LangChain / CrewAI

pip install https://encased.ai/sdk/encased-0.1.0.tar.gz

Node / LangChain.js

npm install https://encased.ai/sdk/encased-0.1.0.tgz

Self-hosted gateway (Enterprise preview) — runs inside your own network

curl -O https://encased.ai/sdk/encased-gateway-0.1.0.tar.gz && tar xzf encased-gateway-0.1.0.tar.gz && docker build -t encased-gateway encased-gateway

cURL / shell

curl -O https://encased.ai/sdk/encased.sh
from encased import Encased
from encased.langchain import EncasedCallbackHandler   # LangChain
from encased.crewai import protect_tools               # CrewAI
enc = Encased()   # reads ENCASED_KEY
agent.invoke(q, config={"callbacks": [EncasedCallbackHandler(enc, agent="support-bot")]})
Agent(role="Researcher", tools=protect_tools([search], enc, agent="researcher"))
# shell:  ENCASED_KEY=... ./encased.sh deploy-bot deploy_prod '{"env":"prod"}' && ./deploy.sh

Live ping test

Paste an agent key and send a test action. Nothing leaves this page except to Encased.

Code examples

# pip install requests
import os, time, requests

ENCASED = "https://encased.ai/api/public/v1"
HEADERS = {"Authorization": f"Bearer {os.environ.get('ENCASED_KEY', 'enc_live_YOUR_KEY')}"}

class Blocked(Exception):
    pass

def guard(agent: str, tool: str, args: dict, timeout_s: int = 900) -> dict:
    """Ask Encased before running a tool. Raises Blocked if it must not run."""
    r = requests.post(f"{ENCASED}/propose", headers=HEADERS, timeout=10,
                      json={"agent": agent, "tool": tool, "args": args})
    r.raise_for_status()
    res = r.json()
    waited = 0
    while res["status"] == "pending":            # paused for a human in the Review Queue
        if waited >= timeout_s:
            raise Blocked("No human decision in time — failing safe")
        time.sleep(2); waited += 2
        res = requests.get(f"{ENCASED}/actions/{res['id']}", headers=HEADERS, timeout=10).json()
    if res["status"] not in ("allowed", "approved"):
        raise Blocked(res.get("reason", "Denied by Encased"))
    return res

def telemetry(agent: str, message: str, level: str = "info"):
    """Optional: stream log lines so they appear in your Encased feed."""
    requests.post(f"{ENCASED}/telemetry", headers=HEADERS, timeout=5,
                  json={"agent": agent, "message": message, "level": level})

# --- usage inside your agent loop ---
try:
    guard("billing-bot", "refund", {"customer": "c_91", "amount": 4500})
    issue_refund("c_91", 4500)                   # your real tool runs only if allowed
except Blocked as e:
    telemetry("billing-bot", f"refund stopped: {e}", "warn")

What the gates check

  • Gate 1 · high-impact tools (transfers, refunds, mass email, production deploys) pause for approval.
  • Gate 2 · destructive commands are blocked; data deletion and money over $1,000 pause.
  • Gate 3 · secrets and private keys leaving the agent are blocked.
  • Gate 4 · personal data (emails, phone and card numbers, ID numbers) and harmful content pause, with the sensitive parts masked.