guides
Intended Documentation
Python ML Pipelines
Gate perception → policy pipelines (PyTorch / JAX) on Intended Authority Tokens using the Python SDK or the raw HTTP API.
Integrating Intended in Python ML Pipelines#
Audience: ML engineers running perception / planning pipelines for physical agents in Python — typically PyTorch / JAX models that consume sensor streams and emit structured commands.
Prereqs: Python 3.10+, an Intended tenant API key (mrt_live_… / mrt_test_…).
Where Intended fits in an ML pipeline#
Every time your model produces a command that becomes real-world motion: classify the command, snapshot the relevant state, and ask for an Authority Token. The token is the credential the controller checks. Without a valid token, the controller falls back to the DAG node's declared safe-default.
This is the same loop as the ROS2 guide without the ROS2 plumbing — useful for standalone perception→command pipelines (AVs outside ROS2, PX4/ArduPilot wrappers), surgical platforms whose planner is a Python service, and agriculture / mining / construction stacks where ROS is not the dominant integration.
Install#
The Python SDK is a thin convenience wrapper over the HTTP API documented in the Authority API reference. Anything you can do with the SDK you can do with requests; the field names and semantics are identical.
Register the actor first#
Token issuance for an unregistered actorIdentity returns 403 actor_not_registered. Register each robot once:
The classify → issue loop#
The token lifetime is the deadline
dagNode.deadlineMs is the token's lifetime — expiresAtMs = issuedAt + deadlineMs. A 500ms deadline yields a 500ms token. Request a fresh token per DAG node; do not treat one token as a session credential.
Pattern: per-frame perception → policy gate#
For perception-heavy pipelines (autonomous driving, agricultural row following, surgical autonomy) you may run the classifier every frame and re-issue tokens only when the cited OI category changes. This caps cloud QPS without sacrificing correctness:
When the classifier shifts the OI category — e.g. OI-2001 (lane change) replacing OI-2003 (mission planning) — a fresh token is required by design: the new category may carry a different policy, safe-default, or approval requirement.
Pattern: vision-grounded intent#
For agents whose intent is perception-determined, carry a fingerprint of the relevant tensor as a parameter so the decision is replayable:
The fingerprint lands in the audit chain so you can replay the decision later — critical for safety reviews of ML-driven autonomy.
Vision is not a safety-rated input
A camera-derived predicate is not safety-rated in the IEC 61508 sense. Mark such predicates safetyRated: false and protocol: "untrusted". If you need redundant human detection, pair a safety-rated curtain/scanner and aggregate with a consensus clause, or downgrade the action to a non-safety OI category. Do not claim a safety rating you do not have — auditors will catch it.
Snapshotting state#
Submit live world state as a predicate → PhysicalStateValue map on each issuance (or stand it up separately with POST /v1/physical/snapshots). The discriminated union and attestation protocols are in the API reference wire format.
Real-time considerations#
The cloud round-trip is the gate today — there is no shipped edge verifier. For pipelines running at ≥30Hz, do not issue per frame; use the cached pattern above and re-issue only on OI transitions. For genuinely real-time loops (≤10ms decision budgets) Python is the wrong language for the hot path: mint tokens from a non-RT Python service and verify them downstream against the cloud-served JWKS. A native Rust verifier is roadmap (see Rust safety-critical firmware).
Testing#
- Point
INTENDED_API_URLat the sandbox base and use anmrt_test_…key. The signer in non-prod is an ephemeral per-process keypair — tokens do not survive a server restart and are not valid against production verifiers. - For replay tests, capture historical perception traces + state snapshots and feed them through your gating wrapper, asserting the decision shape.
See also#
- Authority API reference — every endpoint, field, and error.
- pick-and-place reference — the same flow in a runnable example.
- Safety-case writing — how to argue ML-driven autonomy in a safety case.