Trajectory SDK
Generated Python client for the Trajectory API, with high-level workflows for uploading trajectories, telemetry, and runtime-backed benchmarks.
Install
pip install trajectory-sdk
Quick start
Set TRAJECTORY_API_KEY, then create a client:
from trajectory import Client
client = Client()
benchmarks = client.benchmarks.list(limit=10)
Managed benchmark runtimes inject TRAJECTORY_TOKEN, TRAJECTORY_BASE_URL,
MODEL_ENDPOINT_ID, and TRAJECTORY_TID. The same client uses them for inference, rewards, and
completion:
from trajectory import Client
client = Client()
response = client.chat.completions.create(model="policy", messages=messages)
client.trajectories.log_reward(reward_id="primary", name="correct", value=reward)
client.trajectories.complete(termination_reason="ENV_DONE")
Explicit authentication, URLs, model endpoint headers, and trajectory IDs continue to override the runtime environment.
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. Higher-level operations that
coordinate multiple API calls are available from trajectory.lib:
from trajectory import Client
from trajectory.lib import ingest_events
client = Client()
result = ingest_events(
client,
[
{
"event_type": "agent.completed",
"session_id": "session-123",
"timestamp": "2026-08-28T00:00:00+00:00",
"properties": {"model": "example-model"},
}
],
)
print(result.ingested, result.skipped)
LiteLLM harnesses
Starting with SDK 0.6.6, an existing LiteLLM harness can use this import for policy calls:
from trajectory.lib.litellm import completion
response = completion(model=model, messages=messages, temperature=1.0)
This always uses the injected Trajectory endpoint and credentials. Messages and tools are unchanged.
Keep user/judge calls on native LiteLLM and retain the original loop and grader, then report their
result with the existing
client.trajectories.log_reward(...) and client.trajectories.complete(...) methods.
Development
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
Release files for trajectory-sdk 0.6.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trajectory_sdk-0.6.18.tar.gz | 90.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trajectory_sdk-0.6.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 251.6 kB
Release files / trajectory_sdk-0.6.18.tar.gz
| Download URL | trajectory_sdk-0.6.18.tar.gz |
|---|---|
| Size | 90.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
887d3dbe15665e82e2de66558e09149fb5ddbbea595b5625f8f101f806954bb0
|
|
BLAKE2b-256 checksum How to use checksums |
877e44c6b2a7c55a483925e77679b27c007e7aa95c6285d2bd27b396e34566fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logRelease files / trajectory_sdk-0.6.18-py3-none-any.whl
| Download URL | trajectory_sdk-0.6.18-py3-none-any.whl |
|---|---|
| Size | 161.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45a9d35d012d0920d7b8ca00eacc18956ff6deb26580f6c127b941be64c89ab2
|
|
BLAKE2b-256 checksum How to use checksums |
a0cd0874d7f0548f3ebd3277fcce8cfaaf464a8e22ddde3b0a10f2052a34d92a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency log