oktsec Python SDK
Python client for the oktsec security proxy — identity verification, policy enforcement, and content scanning for AI agent communication.
Install
pip install oktsec
Quick start
from oktsec import Client
with Client("http://localhost:8080", "my-agent") as c:
resp = c.send_message("recipient", "hello from Python")
print(resp.status, resp.message_id)
With Ed25519 signing
from oktsec import Client, load_keypair
kp = load_keypair("./keys", "my-agent")
with Client("http://localhost:8080", "my-agent", keypair=kp) as c:
resp = c.send_message("recipient", "signed message")
print(resp.verified_sender) # True
Async support
import asyncio
from oktsec import AsyncClient
async def main():
async with AsyncClient("http://localhost:8080", "my-agent") as c:
resp = await c.send_message("recipient", "async hello")
print(resp.status)
asyncio.run(main())
Error handling
from oktsec import Client, PolicyError
with Client("http://localhost:8080", "my-agent") as c:
try:
resp = c.send_message("target", "suspicious content")
except PolicyError as e:
print(f"Rejected: {e.response.policy_decision}")
print(f"HTTP {e.status_code}")
for rule in e.response.rules_triggered:
print(f" - {rule.rule_id}: {rule.name} ({rule.severity})")
Generate keypairs
from oktsec import generate_keypair
kp = generate_keypair("new-agent")
kp.save("./keys")
API
Client(base_url, agent_name, keypair=None, timeout=30.0)
send_message(to, content, metadata=None)→MessageResponsehealth()→HealthResponseget_quarantine(quarantine_id)→dict
AsyncClient(base_url, agent_name, keypair=None, timeout=30.0)
Same methods, all async.
load_keypair(directory, name) → Keypair
Loads Ed25519 keys from PEM files. Compatible with oktsec keygen output.
generate_keypair(name) → Keypair
Generates a new Ed25519 keypair.
License
Apache 2.0 — same as oktsec.
Metadata
Release files for oktsec 0.16.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| oktsec-0.16.1.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oktsec-0.16.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.4 kB
Release files / oktsec-0.16.1.tar.gz
| Download URL | oktsec-0.16.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62f11f79ffbfaa9c2ce44bd16631f5a47a64c7dbe1ffbe31b359aa64169fc3e1
|
|
BLAKE2b-256 checksum How to use checksums |
564ae29c7ff562af3a5cfc2254b933b57a30e1b55085f9ccaac3ede0d77ab0f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2026.
Transparency logRelease files / oktsec-0.16.1-py3-none-any.whl
| Download URL | oktsec-0.16.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
669dc6b830f29723c67525da45eed5863d082b8d324039ac73e5da85f87df468
|
|
BLAKE2b-256 checksum How to use checksums |
e4c3d93221a0d12c6ba08c2d6c9be226a0ad3481ac09ad90371df82ab46cfce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2026.
Transparency log