Connect Your AgentPython SDK

Python SDK

Official SDK for Python 3.8+.

The PyPI package is coming soon. For now, use the REST API directly with requests or httpx — see the cURL / REST docs.

Install (coming soon)

pip install aigodfather

Initialize

OptionTypeDescription
api_keystrRequired. Your API key
base_urlstrAPI URL override
debugboolEnable debug logging (default: False)
timeoutintTimeout in seconds (default: 10)
max_retriesintRetries on 429/5xx (default: 3)
default_tagslistTags added to every event
default_metadatadictMetadata merged into every event
on_blockcallableCalled when rule blocks
on_approval_requiredcallableCalled when approval needed

Methods

ai.info(message, metadata) · ai.warning(message, metadata) · ai.error(message, metadata) · ai.critical(message, metadata)

ai.track(event_type, severity, message, metadata, user_id, tags)

ai.action(action_name, resource, severity, message, metadata, ...)

ai.wait_for_approval(approval_id, interval_seconds, timeout_seconds)

ai.check_approval(approval_id) · ai.ping()

Error Classes

ErrorWhen
BlockedErrorRule blocked the action
PlanLimitErrorPlan event limit reached
AgentPausedErrorAgent is paused
python
from aigodfather import AIGodfather, BlockedError
import os

ai = AIGodfather(
    api_key=os.environ[class="tk-str">'AIGODFATHER_API_KEY'],
    debug=False,
    timeout=10,
    max_retries=3,
)

class=class="tk-str">"tk-cmt"># Track a specific action
result = ai.action(
    class="tk-str">'delete_records',
    resource=class="tk-str">'database',
    severity=class="tk-str">'high',
    metadata={class="tk-str">'count': 10000},
)

if result[class="tk-str">'status'] == class="tk-str">'blocked':
    raise Exception(class="tk-str">'Action blocked by AIGodfather')

if result[class="tk-str">'status'] == class="tk-str">'pending_approval':
    print(fclass="tk-str">"Awaiting approval: {result[class="tk-str">'approval_id']}")
    decision = ai.wait_for_approval(result[class="tk-str">'approval_id'])
    if decision[class="tk-str">'status'] != class="tk-str">'approved':
        raise Exception(class="tk-str">'Action denied')

class=class="tk-str">"tk-cmt"># Error handling
try:
    ai.action(class="tk-str">'delete_database', severity=class="tk-str">'critical')
except BlockedError as e:
    print(fclass="tk-str">'Blocked: {e}')