> ## Documentation Index
> Fetch the complete documentation index at: https://docs.emergence.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Type-safe Python client for CRAFT APIs

# Python SDK

The CRAFT Python SDK provides type-safe, auto-generated clients for all platform APIs. Built with Pydantic models and httpx for async support.

## Installation

```bash theme={null}
# Install all SDKs
uv add em-runtime-governance-sdk em-runtime-assets-sdk em-runtime-utils-sdk \
  --index-url https://us-central1-python.pkg.dev/aip-artifacts-store/aipy/simple/

# Or install individually
uv add em-runtime-governance-sdk \
  --index-url https://us-central1-python.pkg.dev/aip-artifacts-store/aipy/simple/
```

## Quick Start

### Create a Client

```python theme={null}
from em_runtime_governance_sdk import AuthenticatedClient

# Create an authenticated client
client = AuthenticatedClient(
    base_url="https://your-instance.emergence.ai/governance",
    token="your-jwt-token",
)
```

### List Organizations

```python theme={null}
from em_runtime_governance_sdk.api.organizations import list_organizations
from em_runtime_governance_sdk.models import OrganizationListResponse

response = list_organizations.sync(client=client)
for org in response.data:
    print(f"{org.id}: {org.name}")
```

### Create a Project

```python theme={null}
from em_runtime_governance_sdk.api.projects import create_project
from em_runtime_governance_sdk.models import ProjectCreate

project = create_project.sync(
    client=client,
    body=ProjectCreate(
        name="My Project",
        description="Data analysis workspace",
    ),
)
print(f"Created project: {project.id}")
```

### Create a Data Connection

```python theme={null}
from em_runtime_assets_sdk import AuthenticatedClient as AssetsClient
from em_runtime_assets_sdk.api.data import create_data_connection
from em_runtime_assets_sdk.models import DataConnectionCreate

assets_client = AssetsClient(
    base_url="https://your-instance.emergence.ai/assets",
    token="your-jwt-token",
)

connection = create_data_connection.sync(
    client=assets_client,
    body=DataConnectionCreate(
        name="analytics-db",
        connection_type="postgres",
        description="Analytics PostgreSQL database",
    ),
)
```

## Async Usage

All SDK methods support async via the `.asyncio()` variant:

```python theme={null}
import asyncio
from em_runtime_governance_sdk.api.organizations import list_organizations

async def main():
    response = await list_organizations.asyncio(client=client)
    for org in response.data:
        print(f"{org.id}: {org.name}")

asyncio.run(main())
```

## Error Handling

```python theme={null}
from em_runtime_governance_sdk.types import Response
from httpx import HTTPStatusError

try:
    response = list_organizations.sync_detailed(client=client)
    if response.status_code == 200:
        data = response.parsed
    elif response.status_code == 401:
        print("Token expired — refresh and retry")
    elif response.status_code == 403:
        print("Insufficient permissions")
except HTTPStatusError as e:
    print(f"HTTP error: {e.response.status_code}")
```

## Package Reference

| Package                     | Covers                                            | Import                                      |
| --------------------------- | ------------------------------------------------- | ------------------------------------------- |
| `em-runtime-governance-sdk` | Organizations, Projects, Permissions, Roles       | `from em_runtime_governance_sdk import ...` |
| `em-runtime-assets-sdk`     | Artifacts, Data Connections, Files, Models        | `from em_runtime_assets_sdk import ...`     |
| `em-runtime-utils-sdk`      | Data Catalog, Scheduling, Context Packs, Memories | `from em_runtime_utils_sdk import ...`      |

## Next Steps

<CardGroup cols={2}>
  <Card title="TypeScript SDK" icon="js" href="/sdks/typescript">
    TypeScript/JavaScript client guide
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Interactive API playground
  </Card>
</CardGroup>
