Metadata-Version: 2.4
Name: trajectory-sdk
Version: 0.6.21
Summary: Generated Trajectory API client and high-level workflows
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.28.1
Requires-Dist: pathspec>=0.12
Requires-Dist: pydantic>=2.0
Dynamic: license-file

# Trajectory SDK

Generated Python client for the Trajectory API, with high-level workflows for uploading
trajectories, telemetry, and runtime-backed benchmarks.

## Install

```bash
pip install trajectory-sdk
```

## Quick start

Set `TRAJECTORY_API_KEY`, then create a client:

```python
from trajectory import Client

client = Client()
benchmarks = client.benchmarks.list(limit=10)
```

Create a trajectory with an authenticated client, then pass its ID explicitly to inference,
rewards, and completion. `MODEL_ENDPOINT_ACCESS_TOKEN`, when set, lets creation reuse the
runtime's precreated trajectory instead of creating another one:

```python
from trajectory import Client

client = Client(api_key="<your-api-key>")
tid = client.trajectories.create().tid
response = client.chat.completions.create(
    model="policy", messages=messages, x_trajectory_id=tid,
)
client.trajectories.log_reward(tid, reward_id="primary", name="correct", value=reward)
client.trajectories.complete(tid, termination_reason="ENV_DONE")
```

`Client` does not read `TRAJECTORY_TID`. Authentication and base URL environment defaults,
and generated model endpoint token/ID defaults, remain supported.

SDK-owned HTTP clients use a 600-second read/write/pool timeout and a 5-second connection timeout.
Supplying `http_client=` inherits that client's timeouts, including a bare HTTPX client's 5-second
default. An explicit `Client(timeout=...)` overrides the supplied client; a resource method's
`timeout=` overrides that request. `timeout=None` disables timeouts. Retry counts are unchanged.

The generated resource methods map directly to the public HTTP API. Benchmark submission
and file-upload workflows are available from `trajectory.lib`; see the
[benchmark guide](docs/guides/benchmarks.mdx).

## Development

```bash
uv run pytest
uv run ruff check .
uv run ruff format --check .
```

The generated client lives in `src/trajectory/`. Handwritten workflows live in
`src/trajectory/lib/`, and tests live in `tests/`.

## License

[Apache 2.0](LICENSE)
