ai-watcher
Python SDK for AIWatcher — AI agent observability and control.
Install
pip install ai-watcher
Quickstart
export AIWATCHER_API_KEY=aw_live_...
One-liner wrapper (Lambda / serverless)
from aiwatcher import track_llm
result = track_llm(
'classify-document',
lambda: openai.chat.completions.create(...),
{
'human_id': customer_id,
'agent_name': 'doc-classifier',
'model': 'gpt-4o',
'framework': 'aws-lambda',
'session_name': 'Classify: invoice',
'input': {'doc_type': 'invoice', 'pages': 3},
}
)
Chained model calls (multi-step pipeline)
from aiwatcher import track_chain
results = track_chain(
steps=[
{
'action': 'extract',
'model': 'gpt-4o',
'fn': lambda: openai.chat.completions.create(...),
'input': {'pages': 3},
},
{
'action': 'classify',
'model': 'claude-sonnet-4-20250514',
'fn': lambda: anthropic.messages.create(...),
'input': {'text': '...'},
},
],
opts={
'human_id': customer_id,
'agent_name': 'shipping-pipeline',
'session_name': 'Process Shipping Document',
}
)
Both wrappers are zero-dependency and never break your app — if AIWatcher is unreachable, the underlying function still runs.
Session context manager (full control)
from aiwatcher import Session, tool
with Session(human_id="you@example.com") as session:
@tool(session)
def search_web(query: str) -> str:
return "results..."
result = search_web("AI agent security")
Full Session config
from aiwatcher import Session, tool
with Session(
api_key="aw_live_...",
human_id="sarah@acme.com",
agent_name="billing-agent",
agent_version="2.0.0",
model="claude-sonnet-4-20250514",
system_prompt="You are a billing assistant.",
tools=["send_invoice", "fetch_invoice"],
framework="langchain",
) as session:
@tool(session, action_class="send", data_scope="financial")
def send_invoice(recipient: str, amount: float) -> dict:
return {"sent": True}
send_invoice("client@acme.com", 1200.00)
API reference
track_llm(action, fn, opts)
| Field | Type | Description |
|---|---|---|
action |
str |
Name of the operation (e.g. "classify-document") |
fn |
Callable |
Zero-argument callable that makes the model call |
opts |
dict |
Session options (see below) |
track_chain(steps, opts)
Each step: {'action': str, 'fn': callable, 'model': str, 'input': dict}
Common opts fields
| Key | Default | Description |
|---|---|---|
human_id |
"anonymous" |
User or customer identifier |
agent_name |
"agent" |
Name of the agent/pipeline |
model |
"unknown" |
Default model (overridden per step in track_chain) |
framework |
"python" |
Runtime (e.g. "aws-lambda", "langchain") |
session_name |
action name | Human-readable session title in the dashboard |
input |
None |
Input metadata to log with the event |
Exceptions
| Exception | When raised |
|---|---|
ExecutionBlockedException |
Policy blocked the tool call |
HitlDeniedException |
Human reviewer denied the action |
AgentwatchAPIError |
Non-2xx response from the API |
AgentwatchConnectionError |
Network error after retries |
Environment variables
| Variable | Default | Description |
|---|---|---|
AIWATCHER_API_KEY |
— | Required. Your aw_live_... key. |
AIWATCHER_API_URL |
https://agentwatch-pi.vercel.app |
Override for self-hosted. |
Metadata
Release files for ai-watcher 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ai_watcher-0.2.4.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ai_watcher-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.8 kB
Release files / ai_watcher-0.2.4.tar.gz
| Download URL | ai_watcher-0.2.4.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42c5581a65c4184eb72c893cf826569bc0c629aadad1ff51ca626345f94c28d3
|
|
BLAKE2b-256 checksum How to use checksums |
75777940accd59d063aacd27be3e0092fe4c048a564a4a67165ceec88add0e2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / ai_watcher-0.2.4-py3-none-any.whl
| Download URL | ai_watcher-0.2.4-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
937b70eb443c06ff6fa5b365e8a45fbf264f8702275f991152debe7ee17be5a8
|
|
BLAKE2b-256 checksum How to use checksums |
b6f9a46390bb9e4e24ac3560794b676cd7136ddd925eb3e4239c0a787af31a7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|