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.1.0

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.1.0
File Size Uploaded Provenance Actions
aiwarden_sdk-0.1.0.tar.gz 43.1 kB With provenance Details for aiwarden_sdk-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 95.9 kB

Release files / aiwarden_sdk-0.1.0.tar.gz

Download URL aiwarden_sdk-0.1.0.tar.gz
Size 43.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d935657b3563f488444a06b757fc2d3ef4154b4d52c3fd1785f8823b1d23cba9
BLAKE2b-256 checksum
How to use checksums
1ad82412293e4c1fc13f98cdeefc0c8b4095135d7c213a234deca7c56a4668f7
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 2, 2026.

Transparency log

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

Download URL aiwarden_sdk-0.1.0-py3-none-any.whl
Size 52.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43880815e724a0f0d6db8ac803aa43a6fdff3d0a8fb71b56efc7ceca959adf35
BLAKE2b-256 checksum
How to use checksums
a670f276763b0737f010cca6da94aa8ec40ca92067136a602fc36ccb359f9d43
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 2, 2026.

Transparency log

Security for aiwarden-sdk 0.1.0

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.1.0.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 2, 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