Skip to main content

aiwarden — Python SDK

Official Python client for aiwarden — AI governance, threat detection, and agent oversight.

Status: alpha. API surface may change before 1.0.0.

Install

pip install aiwarden-sdk

Quickstart

from aiwarden import Aiwarden

client = Aiwarden(api_key="awd_live_...")

# Per-request analysis (regex + AI threat detection, attachments supported)
verdict = client.analyze(prompt="Ignore all previous instructions")
print(verdict.action)  # "block"

# Full agent governance (policies, rate limits, MCP, approvals, lineage)
result = client.agents.execute(
    agent_id="my-foundry-agent",
    action_type="llm_call",
    prompt="Summarize this customer ticket",
    user={"email": "alice@acme.com"},
)
if result.action == "block":
    raise RuntimeError(result.reason)

Agentic Endpoint: aiwarden inside your agent

Install the package in the agent's environment and it governs the whole agent: every model call and every tool it is about to run is checked with aiwarden first, and the verdict is applied (allow, block, hold for approval).

pip install aiwarden-sdk
export AIWARDEN_INSTALL_CODE=aep_...
export AIWARDEN_AGENT_ID=billing-agent      # optional; defaults to <script>@<host>

The install code (created in the portal, Integrations → Agentic Endpoint) expires and has a limit of uses. On its first start the agent swaps it for a credential of its own, kept in ~/.aiwarden (owner-only), so your account key never reaches the machine the agent runs on. An agent without a disk has nowhere to keep it: start that one with AIWARDEN_API_KEY=<your agents key> instead.

One line at the top of the agent:

import aiwarden.endpoint as endpoint
endpoint.install()

Or no code change at all:

aiwarden-run python my_agent.py

What it attaches to (verified against the real libraries in tests/test_endpoint.py and tests/test_endpoint_frameworks.py):

Where What is checked
OpenAI client (chat.completions, responses) the person's message, the tools the model asks for, and tool results before the model reads them
Anthropic client (messages) same
LangChain / LangGraph tools the moment a tool runs, and its output
OpenAI Agents SDK (openai-agents) function tools the moment a tool runs, and its output (Runner.run and Runner.run_streamed, Responses and Chat Completions)
CrewAI tools the moment a tool runs, and its output (native tool calls and ReAct, any model provider)
Your own functions @endpoint.guarded

Because it hooks the model client itself, it also covers agents written with plain API calls and any framework that calls OpenAI or Anthropic through their SDKs.

A blocked tool never runs. By default the model is told with a neutral message and the agent goes on (AIWARDEN_ON_BLOCK=replace); with raise, aiwarden.endpoint.AiwardenBlocked is raised. endpoint.set_user(email) tells aiwarden on whose behalf the agent is acting. endpoint.status() shows what is attached and how many actions were checked, blocked, or let through without a verdict.

Fail-open: if aiwarden cannot be reached, the agent keeps working and the action is counted as ungoverned.

Streaming is governed too (create(stream=True) in both clients): text flows as it arrives and only the events that ask for a tool are held until aiwarden answers.

What the model answers is sent back to aiwarden off the agent's path (text of the last answer of a turn, real tokens, time of the call), so the agent's cost and its answers show up in aiwarden. When the policy's containment can change an answer (retry once, hold or close the session), the package waits for aiwarden's verdict on it; otherwise nothing waits. A short-lived agent should call endpoint.flush() before exiting.

Known limits: the .stream() helpers of both SDKs (chat.completions.stream, responses.stream, messages.stream) are checked on the request side only (create(stream=True) is fully governed in the three APIs); a blocked tool call in the non-streamed Responses API always raises (not inside the OpenAI Agents SDK, where the tool is decided when it runs); answers asked for through with_raw_response / with_streaming_response are checked on the request side only (CrewAI's OpenAI provider does this: its tools are governed by the CrewAI hook, but that model's answers and tokens are not reported); MCP clients do not have their own hook yet. In the OpenAI Agents SDK, handoffs are checked at the model only, and hosted, shell, computer and custom tools are not checked. In CrewAI, the model call is governed only for the providers that use the OpenAI or Anthropic SDK; on_block=raise cannot leave a CrewAI hook, so a denied tool is blocked and the model told; and a crew that clears CrewAI's tool hooks removes aiwarden's too.

What this SDK covers (v0.1)

  • client.analyze() — POST /analyze (per-request, supports text + attachments).
  • client.ask() — POST /ask (full proxy LLM flow with detection + intel logging).
  • client.agents.execute() — POST /api/agent/v1/execute (full agent governance pipeline).
  • client.agents.register() — POST /api/agent/v1/register.
  • client.agents.list_tools() — GET /api/agent/v1/tools.
  • client.agents.status() — GET /api/agent/v1/status.

Fail mode

By default the SDK is fail-open: if aiwarden times out or errors, your agent continues without governance (a WARN is logged). Switch to strict for regulated workloads:

client = Aiwarden(api_key="awd_live_...", fail_mode="closed", timeout=2.0)

Latency budget

timeout is per attempt. On a transient failure (network, 5xx, 429) the SDK retries — 3 times by default — with exponential backoff capped at 8s. So with an unreachable aiwarden the caller can wait on the order of ten seconds before getting the fail-open verdict, not the two the timeout suggests.

If your path is latency-sensitive, cap it:

client = Aiwarden(api_key="awd_live_...", retries=0)   # answers on the first timeout

Async

from aiwarden import AsyncAiwarden

async with AsyncAiwarden(api_key="awd_live_...") as client:
    verdict = await client.analyze(prompt="...")

Documentation

Full reference + integration guides at platform.aiwarden.ai/documentation.

License

MIT

Metadata

Release files for aiwarden-sdk 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiwarden-sdk 0.2.6
File Size Uploaded Provenance Actions
aiwarden_sdk-0.2.6.tar.gz 55.9 kB With provenance Details for aiwarden_sdk-0.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiwarden-sdk 0.2.6
File Interpreter ABI Platform Actions
aiwarden_sdk-0.2.6-py3-none-any.whl Python 3 none any Details for aiwarden_sdk-0.2.6-py3-none-any.whl

Total release size: 123.3 kB

Release files / aiwarden_sdk-0.2.6.tar.gz

Download URL aiwarden_sdk-0.2.6.tar.gz
Size 55.9 kB
Tags Source
SHA-256 checksum
How to use checksums
92161f10c106f7a42ce9365b584effd5a7a9a61fcd9c60108c8f6e00b14bfbe7
BLAKE2b-256 checksum
How to use checksums
d737765e963be6cd71e66bedd8de9e7f6956576750980fb1cb0a48dcea13ff55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 5, 2026.

Transparency log

Release files / aiwarden_sdk-0.2.6-py3-none-any.whl

Download URL aiwarden_sdk-0.2.6-py3-none-any.whl
Size 67.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd476a597f3db2aea1e4fa4e9467b0cf462ec657a56ed67af61794b26a54fe5e
BLAKE2b-256 checksum
How to use checksums
e7e8998c72b60d8409fb1d97627566a25992955505cd5dfd0eb195f0e7267054
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 5, 2026.

Transparency log

Security for aiwarden-sdk 0.2.6

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aiwarden_sdk-0.2.6.tar.gz

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 Dec 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page