Skip to main content

Runtime security for AI agents — Python SDK for detecte.xyz

Project description

detecte (Python)

PyPI Python

Runtime security for AI agents. The Python SDK for detecte.xyz — a one-to-one companion to @detecte/sdk.

Install

pip install detecte

Quickstart

import os
from detecte import Detecte

detecte = Detecte(api_key=os.environ["DETECTE_API_KEY"])

decision = detecte.verify(
    agent="support_bot",
    action="refund_order",
    params={"order_id": "ord_8821", "amount": 49.99},
)

if not decision.allowed:
    raise RuntimeError(f"Blocked: {decision.reason}")

Async

from detecte import AsyncDetecte

async def main():
    detecte = AsyncDetecte(api_key="sk_test_...")
    decision = await detecte.verify(agent="bot", action="x")
    print(decision.allowed)

Resources

  • detecte.agents.list() / .get(id) / .create(...)
  • detecte.policies.list() / .create(...) / .dry_run(policy=..., sample_size=1000)
  • detecte.incidents.list() / .resolve(id)
  • detecte.audit.list(...)
  • detecte.approvals.get(decision_id) / .wait(decision_id)
  • detecte.scans.run(agent=..., system_prompt=...)

Webhooks

from detecte import verify_webhook, WebhookVerificationError

try:
    verify_webhook(
        payload=raw_body,
        signature=request.headers["Detecte-Signature"],
        secret=os.environ["DETECTE_WEBHOOK_SECRET"],
    )
except WebhookVerificationError:
    return Response(status=401)

LangChain integration

from detecte import Detecte
from detecte.integrations.langchain import DetecteCallbackHandler

detecte = Detecte()
handler = DetecteCallbackHandler(detecte=detecte, agent_id="agent_xxx")
executor = AgentExecutor.from_agent_and_tools(
    agent=...,
    tools=...,
    callbacks=[handler],
)

License

MIT — copyright Detecte, Inc.

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

detecte-0.1.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

detecte-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file detecte-0.1.1.tar.gz.

File metadata

  • Download URL: detecte-0.1.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detecte-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ea1902925829e35aa9f45b45efec5ce53d8630ec71360e12f220a0ff768e64f
MD5 ab693134508e48584f7c5dc4fe0e1f71
BLAKE2b-256 1c7eca672903e08b4945b1e0311210da4920170408e33c738530d7ba938c5f25

See more details on using hashes here.

Provenance

The following attestation bundles were made for detecte-0.1.1.tar.gz:

Publisher: release.yml on detecte-xyz/detecte-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 detecte-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for detecte-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91c8c89fa0fb0e203038c29ac238e0f7d4395807329cb9286d5d1c101359b893
MD5 79763db02fd5fd82413824cda1b8855e
BLAKE2b-256 06b50586a87e44453271945ca3190cf14ace2a36479060a15c52ff6e6e871715

See more details on using hashes here.

Provenance

The following attestation bundles were made for detecte-0.1.1-py3-none-any.whl:

Publisher: release.yml on detecte-xyz/detecte-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