Skip to main content

Klent SDK for Python — control layer for AI agents

Project description

klent-sdk

The Python SDK for Klent — the control + observability layer for AI agents in production. Wraps every tool call your agent makes through Klent's policy engine: allow, deny, modify, steer to a different tool, or pause for approve (human-in-the-loop, synchronous wait via dashboard or email).

PyPI Python License

Install

pip install klent-sdk

Or with Anthropic agent helpers:

pip install 'klent-sdk[anthropic]'

Quick start

import os
from klent_sdk import KlentClient, run_tool

klent = KlentClient(api_key=os.environ["KLENT_API_KEY"])
execution = klent.start_execution(agent_id="my-agent")

result = run_tool(
    klent,
    execution_id=execution["id"],
    tool="transfer_funds",
    input={"amount": 50_000, "currency": "USD"},
    execute=lambda inp: transfer_funds(**inp),
    approval={"wait": {"timeout_ms": 30 * 60_000}},
)

if result["status"] == "allowed":
    print("output:", result["output"])
elif result["status"] == "denied":
    print("blocked:", result["reason"])

The approval.wait kwarg makes run_tool block synchronously until a human resolves the action on the dashboard (or via the email Resend sends with Approve / Reject buttons), then runs the tool and returns its output.

Full docs at klent.dev/docs.

Anthropic agent helper

A higher-level orchestrator runs an Anthropic agent loop with every tool call gated through Klent:

from anthropic import Anthropic
from klent_sdk import KlentClient
from klent_sdk.anthropic import run_anthropic_agent

result = run_anthropic_agent(
    anthropic=Anthropic(),
    klent=KlentClient(api_key=...),
    agent_id="research-agent",
    system="You are a helpful research assistant...",
    tools=[...],
    user_message="Find the top 3 things...",
)

See klent_sdk/anthropic.py for the full surface.

Develop

git clone https://github.com/klentlabs/klent-sdk-python.git
cd klent-sdk-python
python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
pytest

Publishing

Tag sdk-py-vX.Y.Z.github/workflows/publish-sdk-python.yml builds wheel + sdist and publishes to PyPI via OIDC trusted publisher. No tokens stored — auth is the GitHub Actions OIDC id-token verified against PyPI's trusted-publisher config for this repo.

Project

License

Apache-2.0. See LICENSE.

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

klent_sdk-0.0.2a1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

klent_sdk-0.0.2a1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file klent_sdk-0.0.2a1.tar.gz.

File metadata

  • Download URL: klent_sdk-0.0.2a1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klent_sdk-0.0.2a1.tar.gz
Algorithm Hash digest
SHA256 b990abd94f8fd0767e3706cc898a5a28f71cc16127213ad4a0e507dae16844c1
MD5 c6f2916ee850e54858a30845278f2eaa
BLAKE2b-256 aefdc04912281a731b8cf5686aa1525bb5f42ebe4845a2c042b4f3c6ad5d96e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for klent_sdk-0.0.2a1.tar.gz:

Publisher: publish-sdk-python.yml on klentlabs/klent-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klent_sdk-0.0.2a1-py3-none-any.whl.

File metadata

  • Download URL: klent_sdk-0.0.2a1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for klent_sdk-0.0.2a1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c3bbd210c7baa23bbaac233056e7ec3030ca06bba7c4992d1ec4d8a15f4ca73
MD5 c39ecaa527f40ef55ff8bc4c41c702c8
BLAKE2b-256 9496802e9409c92137bde711b378144936c6c26959ccb1027125ee186f14cb89

See more details on using hashes here.

Provenance

The following attestation bundles were made for klent_sdk-0.0.2a1-py3-none-any.whl:

Publisher: publish-sdk-python.yml on klentlabs/klent-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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