# vantageai — Python SDK

> **Vendor-neutral governance SDK for enterprise AI agents.**

## Install

```bash
pip install vantageai
```

## Quick Start

```python
import asyncio
from vantageai import VantageClient

async def main():
    client = VantageClient(api_key="your-api-key", agent_id="your-agent-id")

    # Log an event
    await client.log_event(type="llm_call", input={"model": "gpt-4o"})

    # Execution trace
    trace = await client.start_execution(session_id="session-123")
    await client.log_step(trace.id, step={
        "stepNumber": 1, "type": "tool_call", "toolName": "search"
    })
    await client.complete_execution(trace.id, status="complete")

    # Policy evaluation
    result = await client.evaluate(
        action_type="send_email",
        action_payload={"to": "user@example.com"},
    )
    if result.decision == "block":
        print("Action blocked:", result.reason)
    elif result.decision == "pending_approval":
        approval = await client.wait_for_approval(result.approval_request_id)
        print("Approved by:", approval.resolved_by)

    # Intent shift enforcement
    intent = await client.start_intent(declared_intent="Reconcile Q1 invoices")
    shift = await client.log_shift(
        intent.id,
        observed_intent="Approve duplicate payment of $28,000",
        severity="critical",
    )
    if shift.decision == "block":
        print("Blocked by policy")
    elif shift.decision == "pending_approval":
        approval = await client.wait_for_approval(shift.approval_request_id)
        print("Approved by:", approval.resolved_by)

asyncio.run(main())
```

## Sync Usage

```python
from vantageai import VantageClientSync

client = VantageClientSync(api_key="your-api-key", agent_id="your-agent-id")
client.log_event(type="llm_call")
```

## LangChain Integration

```python
from vantageai import VantageClient
from vantageai.integrations.langchain import VantageCallbackHandler

client = VantageClient(api_key="your-api-key", agent_id="your-agent-id")
handler = VantageCallbackHandler(client)

# Pass handler to any LangChain chain/agent
chain.invoke({"input": "..."}, config={"callbacks": [handler]})
```

## Admin & Settings APIs

```python
from vantageai import VantageClientSync

client = VantageClientSync(api_key="your-api-key", agent_id="your-agent-id")

# Webhooks
webhook = client.create_webhook(
    url="https://httpbin.org/post",
    events=["policy_blocked", "intent_shift"],
)
client.list_webhooks()
client.delete_webhook(webhook.id)

# Members + audit log
client.list_members()
client.get_audit_log()

# Retention
client.get_retention_policy()
client.update_retention_policy(events_retention_days=90, traces_retention_days=90)

# Billing
client.get_billing_subscription()
client.get_billing_usage()
client.create_billing_upgrade("pro")
client.create_billing_portal()
```
