Metadata-Version: 2.3
Name: stax-sdk
Version: 0.1.0
Summary: Add your description here
Author: Cameron Sechrist
Author-email: Cameron Sechrist <cam@stax.ai>
Requires-Dist: pydantic>=2
Requires-Dist: cloudevents
Requires-Dist: httpx>=0.27
Requires-Dist: openapi-python-client>=0.20 ; extra == 'dev'
Requires-Dist: ruff ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: python-semantic-release ; extra == 'dev'
Requires-Python: >=3.14
Provides-Extra: dev
Description-Content-Type: text/markdown

# stax-sdk

SDK for Stax.ai APIs: automations (Knative Functions), CX/TA API clients, and logging.

This project uses **uv** for dependency management and running.

## Setup

```bash
uv sync
```

For code generation (OpenAPI → client code). TA and CX clients are generated into `src/stax_sdk/ta/_generated/` and `src/stax_sdk/cx/_generated/` (no nested pyproject.toml). Typed group classes are then generated for both.

```bash
uv sync --all-extras
uv run python scripts/generate_clients.py
```

## Usage

**Grouped API (recommended):** Use `TaAPI` / `CxAPI` for sync and `AsyncTaAPI` / `AsyncCxAPI` for async.

```python
from stax_sdk import TaAPI, AsyncTaAPI, CxAPI, AsyncCxAPI

# Sync TA
ta = TaAPI(inject_headers=my_inject_headers)
ta.tpa.account_create(body=...)
ta.stack.list()

# Async TA
async_ta = AsyncTaAPI(inject_headers=my_inject_headers)
await async_ta.tpa.account_create(body=...)

# Sync CX
cx = CxAPI(inject_headers=my_inject_headers)
cx.misc.update_changelog(body=...)

# Async CX
async_cx = AsyncCxAPI(inject_headers=my_inject_headers)
await async_cx.misc.update_changelog(body=...)
```

- **Automations:** Use `@stax_automation(EventDataModel)` or `@stax_automation_async(EventDataModel)`; the decorated handler receives `(event_data, StaxContext)` and returns an ASGI callable for Knative func-python.
- **CX/TA clients:** Use `TaAPI(...)` or `CxAPI(...)` for grouped endpoints. Lower-level: `stax_sdk.cx.Client` / `stax_sdk.ta.Client` (sync) and `AsyncClient` (async).
- **Logging:** Call `stax_sdk.configure_logging()`; set `LOG_FORMAT=json` for JSON logs to stdout.

## Environment

- `STAX_MODULE_ID` — set in StaxContext and available to your auth header helper
- `STAX_KEY` — credentials; your `inject_headers` helper reads this and sets request headers
- `LOG_FORMAT` — `json` for JSON logs, otherwise human-readable
