Skip to content

SDK Installation

SDK Installation

Python

pip install xybern

Two ways to use it, both backed by the same engine:

# Zero-code: discovers LangChain / CrewAI / LangGraph / AutoGen / OpenAI Agents /
# MCP / Semantic Kernel / LlamaIndex agents, registers them, authorises their actions.
import xybern
xybern.auto.connect()                  # observe first
xybern.auto.connect(mode="enforce")    # then enforce

# Explicit: one call per protected action in your own code.
from xybern import Xybern
xy = Xybern(agent_id="procurement-agent")
d = xy.authorize("purchase_order.create", context={"amount": 750000, "currency": "SAR"})
if d.allowed: ...

The key is read from XYBERN_API_KEY, from xybern login, or passed as api_key=. Point at a relay or a dedicated / sovereign deployment with XYBERN_BASE_URL.

CLI:

xybern login        # device-code sign-in, picks your workspace key
xybern agents       # dry run: what would be discovered
xybern doctor       # per-framework enforceability report
xybern enforce on   # switch from observe to enforce

TypeScript / JavaScript

npm install @xybern/sdk
import { Xybern } from '@xybern/sdk';

const xybern = new Xybern({ apiKey: process.env.XYBERN_API_KEY! });
const decision = await xybern.enforce.intercept({
  actionType: 'email.send',
  actionContent: 'Send Q4 report to cfo@company.com',
  agentId: 'reporting-agent',
  metadata: { recipient_external: false },
});
if (decision.decision === 'allow') { /* execute */ }

Other languages

Call the REST API directly, see the Quick Start. Java and .NET clients are on the roadmap; the contract is a single POST /v1/enforce/intercept.

LLM gateway (no SDK at all)

OPENAI_BASE_URL=https://www.xybern.com/gateway/openai/v1
OPENAI_DEFAULT_HEADERS='{"X-Xybern-API-Key": "xb_live_…"}'

See LLM Gateway.

Legacy download

Older docs told you to download xybern.py from the website. That file is deprecated; use pip install xybern.