Skip to main content

Python SDK for Kaplaix AI agent governance platform

Project description

kaplaix — Python SDK

Python SDK for instrumenting AI agents with Kaplaix.

Requirements

  • Python >= 3.10
  • httpx (installed automatically)

Installation

pip install kaplaix

Quick start

from kaplaix import KaplaixClient

client = KaplaixClient(api_key="al_live_...")

with client.session(agent_id="my-agent") as session:
    session.log_tool_call("web_search", "sha256-of-args", response_status=200)

Client options

Parameter Type Default Description
api_key str required Tenant API key (al_live_...)
base_url str https://api.kaplaix.io API base URL
timeout_ms float 10000 Request timeout in milliseconds
retries int 3 Retry attempts on transient errors (429, 502, 503, 504)
metadata SdkMetadata Optional environment metadata

Session

session = client.session(
    agent_id="my-agent",
    session_id="optional-custom-id",  # any non-empty string; UUID generated if absent
)

Use as a context manager (calls end() automatically) or manage lifecycle explicitly.

Event helpers

Tool call

session.log_tool_call(
    tool_name="database_query",
    arguments_hash="sha256-hex",   # hash of args — never log raw args
    response_status=200,           # optional HTTP status
    endpoint="/api/query",         # optional
)

Data movement

session.log_data_movement(
    operation="export",            # "read" | "write" | "delete" | "export"
    object_ids=["record-001"],
    diff_summary="Exported 1 record",  # optional
)

Approval

session.log_approval(
    approver_id="user-42",
    scope="delete:crm:customers:bulk",
    decision="rejected",           # "approved" | "rejected"
)

Environment

session.log_environment(
    is_sandbox=False,
    network_segment="prod-vpc",
    workspace="production-cluster",
)

Raw event

session.log_event(
    category="reasoning",
    payload={"summary": "Decided to proceed with deletion"},
)

Retry behavior

The SDK retries on HTTP 429, 502, 503, and 504 using exponential backoff with full jitter. Non-retryable errors (4xx) are raised immediately.

Error handling

from kaplaix import KaplaixError, KaplaixNetworkError, KaplaixTimeoutError

try:
    session.log_tool_call("tool", "hash")
except KaplaixError as e:
    print(f"API error {e.status_code}: {e.body}")
except KaplaixTimeoutError:
    print("Request timed out")
except KaplaixNetworkError as e:
    print(f"Network error: {e.__cause__}")

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

kaplaix-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

kaplaix-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file kaplaix-0.1.0.tar.gz.

File metadata

  • Download URL: kaplaix-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for kaplaix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a76ae7fc9116f1bb82aece2d659607cff592ca02330d19cc4b048c03292e7126
MD5 dacff873c6c8f52e7b3dfec84b7c74a4
BLAKE2b-256 933952f035f35f3baa37eb121b182073fa488911cfcdc160f7426f47638bcace

See more details on using hashes here.

File details

Details for the file kaplaix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kaplaix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for kaplaix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8caa947dfc4f7b21ecf2bd00b2d0ba97a9d4631577582c1f8238c9a45b495a29
MD5 0077d8dd9629dd08c5163df18152d594
BLAKE2b-256 11f36e08bbf2a30a47747679bb2f2ece3a4d31728e507b7fecefada109a4b9ba

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