Metadata-Version: 2.4
Name: trust3-ai-collector-sdk
Version: 0.1.0
Summary: Python SDK for pushing AI-asset inventory snapshots to Trust3 AI governance.
Author-email: Trust3 Team <support@trust3.ai>
License-Expression: LicenseRef-Proprietary
Project-URL: Documentation, https://docs.trust3ai.com
Project-URL: Homepage, https://pypi.org/project/trust3-ai-collector-sdk/
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.5.0
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: httpx>=0.27.0; extra == "dev"

# trust3-ai-collector-sdk

Python SDK for pushing AI-asset inventory snapshots directly to Trust3 governance.

Describe your agents, tools, models, identities, and the relationships between them using a
typed generic model. The SDK maps the snapshot to the governance bulk ingest format and POSTs
it to the governance API.

- **Direct** — pushes to the Trust3 governance bulk ingest API
- **Typed** — closed enums prevent invalid asset or relationship kinds at construction time
- **Resilient** — automatic retry on transport errors and 5xx responses
- **Idempotent** — push a full snapshot every time; governance upserts, so re-sending is safe

---

## Installation

```shell
pip3 install trust3-ai-collector-sdk
```

Requires Python ≥ 3.9 and a Trust3 governance API key. See the
[AI Assets Collector documentation](https://docs.trust3ai.com/ai-assets-collector/index.html)
for platform setup and credentials.

---

## Quick start

```python
import os
from trust3_ai_collector_sdk import (
    Asset, AssetKind, IdentityKind,
    InventoryClient, InventoryClientConfig,
    InventorySnapshot,
    Relationship, RelationshipKind,
)

snap = InventorySnapshot(
    source="my_platform",
    account="prod.example.com",
    vendor="Acme Corp",
    product_name="My Platform",
    environment="prod",
)
snap.assets += [
    Asset(kind=AssetKind.AGENT, id="billing_agent", name="Billing Agent",
          owners=["ops-team@example.com"], provider="openai", model_name="gpt-4o"),
    Asset(kind=AssetKind.MODEL, id="openai:gpt-4o", name="GPT-4o", provider="openai"),
]
snap.relationships += [
    Relationship(kind=RelationshipKind.USES_MODEL,
                 from_id="billing_agent", from_kind=AssetKind.AGENT,
                 to_id="openai:gpt-4o", to_kind=AssetKind.MODEL),
]

config = InventoryClientConfig(
    api_server_host=os.environ["TRUST3_API_SERVER_HOST"],
    api_key=os.environ["TRUST3_API_KEY"],
)

with InventoryClient(config) as client:
    result = client.submit(snap)
    print(f"pushed {result.assets_pushed} assets, governance HTTP {result.governance_status}")
```

Set `TRUST3_API_SERVER_HOST` to your Trust3 API hostname (for example `https://api.na.trust3ai.com`)
and `TRUST3_API_KEY` to your governance API key.

---

## Configuration

```python
config = InventoryClientConfig(
    api_server_host="https://api.na.trust3ai.com",
    api_key="your-trust3-api-key",
)
```

| field | description |
|-------|-------------|
| `api_server_host` | Trust3 API server base URL |
| `api_key` | Your Trust3 governance API key |

---

## Error handling

```python
from trust3_ai_collector_sdk.errors import InventoryValidationError, InventoryTransportError

try:
    result = client.submit(snap)
except InventoryValidationError as e:
    print(f"rejected (HTTP {e.status_code}): {e.response_text}")
except InventoryTransportError as e:
    print(f"failed after retries: {e}")
```

---

## License

Proprietary software. Copyright Privacera, Inc. All rights reserved. Use is subject to your
Trust3 AI agreement with Privacera.

---

## Further reading

- [Trust3 AI documentation](https://docs.trust3ai.com/)
- [AI Assets Collector](https://docs.trust3ai.com/ai-assets-collector/index.html)
