Prime Traces SDK
Upload and query training, evaluation and inference traces through the Prime Traces service.
Features
- Content-addressed uploads - Batches are identified by the SHA-256 of their exact bytes, so interrupted uploads are safe to rerun and never store twice
- Deterministic batching - JSONL files are split at byte thresholds without rewriting a single line
- Typed reads - Cursor-paginated summaries over extracted columns and raw document retrieval
- Type-safe - Full type hints and Pydantic models
- No CLI dependencies - Pure SDK, usable in producers and services
Installation
uv add prime-traces
or with pip:
pip install prime-traces
Quick Start
Upload from memory
upload_records accepts JSON-compatible mappings as well as objects exposing
to_record(). Verifiers Trace / Episode and prime-rl Rollout objects
provide that method, so producers can upload completed records without writing
an intermediate JSONL file:
from prime_traces import LineFormat, TracesClient
client = TracesClient() # PRIME_API_KEY / ~/.prime/config.json
# Iterable[vf.Trace] or Iterable[prime_rl.orchestrator.types.Rollout]
receipts = client.upload_records(
traces,
context={"source": "prime-rl", "run_id": "run_9f3k2m"},
)
# Iterable[vf.Episode] for multi-agent runs
receipts = client.upload_records(
episodes,
line_format=LineFormat.EPISODE,
context={"source": "verifiers"},
)
Records are serialized lazily and fed into bounded batches, so this neither
buffers the complete iterable nor round-trips through the filesystem. Callers
that already have encoded JSONL bytes can use upload_lines directly.
Upload a completed JSONL file
from prime_traces import TracesClient, LineFormat
client = TracesClient() # PRIME_API_KEY / ~/.prime/config.json
# One bare Verifiers trace per line:
receipts = client.upload_file("traces.jsonl", context={"source": "hosted_eval"})
# One complete episode per line (multi-agent runs):
receipts = client.upload_file(
"episodes.jsonl",
line_format=LineFormat.EPISODE,
context={"source": "hosted_eval", "suite_commit": "a1f39c2"},
)
Uploads are content-addressed: each request is identified by the SHA-256 of its
exact uncompressed JSONL bytes and sent with an Idempotency-Key. Rerunning an
interrupted upload re-reads the file, reproduces the same bytes and keys, and
the service replays committed receipts without storing anything twice. A 400
rejection stops the upload with a bounded error code (ErrorCode); 429/503 and
gateway 502/504 are retried with the same bytes, honoring Retry-After.
Query
page = client.list(run_id="run_9f3k2m", reward_min=0.9, has_error=False)
for summary in page.items:
print(summary.trace_id, summary.score)
for summary in client.iter(task_id="tb2-0187"): # paginates for you
...
summary = client.get("8d3f1a2b...")
raw = client.get_raw("8d3f1a2b...") # exact stored trace document
client.download_raw("8d3f1a2b...", "t.json") # streamed, for large traces
client.delete("8d3f1a2b...") # NotFoundError if the owner has no such trace
client.delete_run("run_9f3k2m") # one mutation, synchronous, no job handle
Deletion is not a no-op on absent rows: the service checks existence first and
answers 404, so repeating a delete that already succeeded raises
NotFoundError. (The design docs specify it as idempotent; this tracks the
service as built.) Failures known to occur before delivery, 429 responses, and
service-coded 503 refusals are retried. Ambiguous response-path failures and
gateway 502/503/504 responses are surfaced as AmbiguousDeleteError without
replaying the deletion, because a retry could delete a trace written after the
first request.
Trace point reads/deletes and episode point/member reads currently reject IDs
containing /. ASGI decodes an encoded slash before matching the service's
/{resource_id} routes, so those IDs cannot be addressed until the service
accepts path-valued route parameters.
Episodes are read-only resources:
page = client.list_episodes(
run_id="run_9f3k2m",
environment_id="terminal-bench-2",
)
for episode in page.items:
print(episode.episode_id, episode.outcome)
if page.items:
episode_id = page.items[0].episode_id
detail = client.get_episode(episode_id) # + member aggregate under .traces
print(detail.error.type, detail.traces.trace_count)
# Member trace summaries use the trace filters (except sort) and pagination.
client.list_episode_traces(episode_id, has_error=True)
Response shapes mirror the service's pinned models: pages are
{items, next_cursor}, a trace summary nests model / score / execution,
an episode nests error and (on point lookup) the member-trace aggregate
under traces, and unrecorded fields come back as null.
Configuration
| Source | Meaning |
|---|---|
PRIME_API_KEY |
Platform API token (needs traces:read / traces:write scopes) |
PRIME_TEAM_ID |
Optional team context, sent as X-Prime-Team-ID |
PRIME_TRACES_URL |
Base URL of the Prime Traces service; defaults to the platform API base URL. For the service's local compose stack: http://localhost:8083 |
~/.prime/config.json |
Shared prime CLI config (api_key, team_id, traces_url) |
Not implemented yet (open v0 contract decisions)
- Exports, in any form. The service publishes
GET /traces/exportand the two job routes, but all three handlers raiseNotImplementedError— answered as 500, not the 501 they document — and the streaming route declares no query parameters, so there is no filter vocabulary to bind to. Wrapping it now would ship a method that cannot succeed. /searchand free-text queries — deferred with thetrace_componentsprojection.- Typed dot-path predicates (
traces.query) — needs the server-side field registry. - An async client — the other prime SDKs ship sync/async pairs, and the main producers (verifiers, prime-rl) are async; add once the sync surface settles rather than freezing a duplicated API now.
Documentation
For detailed documentation, visit the Prime Traces SDK documentation.
Related Packages
- prime - Prime CLI (
prime traces ...commands) - prime-sandboxes - Sandboxes SDK
- prime-evals - Evals SDK
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prime_traces-0.0.1.tar.gz.
File metadata
- Download URL: prime_traces-0.0.1.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67c59332da68303d7754789161f86057eb48e25e4b0c23de2f04a18cf4065182
|
|
| MD5 |
144f6a180fa92846b241fa4f24c1d4ea
|
|
| BLAKE2b-256 |
98996d3f24a1e771a7f0f3450d98664b4f23007cd1901b1ce17573e53f48d0df
|
Provenance
The following attestation bundles were made for prime_traces-0.0.1.tar.gz:
Publisher:
release-traces.yml on PrimeIntellect-ai/prime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prime_traces-0.0.1.tar.gz -
Subject digest:
67c59332da68303d7754789161f86057eb48e25e4b0c23de2f04a18cf4065182 - Sigstore transparency entry: 2460228088
- Sigstore integration time:
-
Permalink:
PrimeIntellect-ai/prime@169bf2dc8fdeb8a5b3fc1c5eee8e6fa6e030f2fe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PrimeIntellect-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-traces.yml@169bf2dc8fdeb8a5b3fc1c5eee8e6fa6e030f2fe -
Trigger Event:
push
-
Statement type:
File details
Details for the file prime_traces-0.0.1-py3-none-any.whl.
File metadata
- Download URL: prime_traces-0.0.1-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfdd80000580412fe9ebbd3305a64003584cff6b5e7252122ea10d4e220e47c0
|
|
| MD5 |
d87724982f172004fb734e231900eec2
|
|
| BLAKE2b-256 |
54d08f68531db7c61668aae4889ea2cf3b012632daafd489f1b302c46b9bb6a8
|
Provenance
The following attestation bundles were made for prime_traces-0.0.1-py3-none-any.whl:
Publisher:
release-traces.yml on PrimeIntellect-ai/prime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prime_traces-0.0.1-py3-none-any.whl -
Subject digest:
bfdd80000580412fe9ebbd3305a64003584cff6b5e7252122ea10d4e220e47c0 - Sigstore transparency entry: 2460228212
- Sigstore integration time:
-
Permalink:
PrimeIntellect-ai/prime@169bf2dc8fdeb8a5b3fc1c5eee8e6fa6e030f2fe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PrimeIntellect-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-traces.yml@169bf2dc8fdeb8a5b3fc1c5eee8e6fa6e030f2fe -
Trigger Event:
push
-
Statement type: