Skip to main content

Kybernis Python SDK

Project description

Kybernis Python SDK (beta)

This SDK lets multi-agent builders (LangGraph, CrewAI, LangChain) route tool calls through the Kybernis execution gate, emit execution spans, and report tool health/cost.

Install (local dev)

  • Add sdk/python to your PYTHONPATH or vendor the package into your app.
  • Or set KYB_SDK_PATH to the absolute path of sdk/python.

Minimal usage

  • Set env: KYB_API_BASE, KYB_API_KEY, KYB_TENANT_ID, KYB_RUN_ID
  • Enable SDK: KYB_SDK_ON=1

Audit CLI

  • Install the package and run kybernis-audit templates
  • Quickstart a local manual audit recipe with kybernis-audit quickstart --recipe mutation
  • Create a run with kybernis-audit run --template-id DARE --source-run-id <run_id>
  • Replay a run with kybernis-audit replay --audit-run-id <audit_run_id>

The SDK provides:

  • KybernisClient for tool registry, health, events, cost, and gate requests.
  • kyb_tool decorator to gate tool calls before framework-level HITL.
  • install() auto-patches requests/httpx to inject Kybernis headers.
  • derive_idempotency_key() to match proxy idempotency hashing.
  • span() helpers for non-HTTP execution spans.
  • Side-effect helpers: webhook(), email(), charge().

SDK modes (A2A + proxy and A2A + MCP)

You can choose how the SDK routes governance and enforcement:

  • Proxy-first: auto install HTTP patches + A2A lifecycle only.
  • MCP-first: A2A lifecycle + MCP tools for governance.
  • Hybrid: both proxy patches and MCP tools.

Python:

from kybernis import KybernisSDK

sdk = KybernisSDK(agent, mode="hybrid", tool_map={"chat": "kyb.decide"})

Env:

KYB_SDK_MODE=hybrid
KYB_SDK_METHOD_TOOL_MAP={"chat":"kyb.decide"}

Method interception controls

  • KYB_SDK_AUTO_INTERCEPT=1 wrap all public methods on the framework instance.
  • KYB_SDK_PROXY_MODE=1 return a proxy object that intercepts methods via __getattr__.
  • KYB_SDK_METHOD_ALLOWLIST=chat,run only wrap these methods.
  • KYB_SDK_METHOD_BLOCKLIST=render,draw skip these methods.

Env flags

  • KYB_SDK_ON=1 enable SDK
  • KYB_API_BASE control plane base URL
  • KYB_API_KEY auth token (preferred)
  • KYB_API_TOKEN auth token (legacy)
  • KYB_TENANT_ID tenant scope
  • KYB_RUN_ID run scope (set per run)
  • KYB_SDK_MODE=proxy-first|mcp-first|hybrid SDK routing mode
  • KYB_SDK_METHOD_TOOL_MAP JSON map of method name -> MCP tool name
  • KYB_TOOL_REGISTER=1 auto-register tools
  • KYB_GATE_AUTO_APPROVE=1 auto-approve gate unless overridden
  • KYB_TOOL_CALL_LIMIT=0 per-tool call limit (0 = unlimited)
  • KYB_ENFORCE_EGRESS=1 fail-closed if HTTP(S)_PROXY is not set

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kybernis-0.1.4.tar.gz (51.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kybernis-0.1.4-py3-none-any.whl (64.3 kB view details)

Uploaded Python 3

File details

Details for the file kybernis-0.1.4.tar.gz.

File metadata

  • Download URL: kybernis-0.1.4.tar.gz
  • Upload date:
  • Size: 51.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for kybernis-0.1.4.tar.gz
Algorithm Hash digest
SHA256 276537f00defdee684daaaf6e5d9a0ab5bb1e773663c793339aaae9227aae5a0
MD5 3ae3e92e915e2228ed55e69c1e2ae2a2
BLAKE2b-256 9a55a7903ee93c5d95436a7b46ca45f7230d58425686214ea6838ecac0775d47

See more details on using hashes here.

File details

Details for the file kybernis-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: kybernis-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 64.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for kybernis-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2632de58929ee15050d7fc36258caed3ef13f097491f77f7c51f9363021ed4a4
MD5 a3ebefd17a362a826378be5d7a0db333
BLAKE2b-256 ad7894cb3c373749452daa477e4f607c9249d0cec40df94cc9cb41b6466ce7b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page