Make every result path easy to operate.
Status: Beta · Python
0.0.3· TypeScript0.0.3Companion docs: Authentication · Language compatibility · Result
1. Install
Install the SDK
Your language choice stays selected across the docs.
- Python
- TypeScript
pip install trinitite==0.0.3
npm install @trinitite/sdk@0.0.3
2. Choose an environment
Set the API key and environment together. A mismatch stops at startup, before a development key can reach the production endpoint.
Configure the environment
- Python
- TypeScript
TRINITITE_API_KEY=trnt_test_...
TRINITITE_ENV=test
TRINITITE_API_KEY=trnt_test_...
TRINITITE_ENV=test
Environment keyring
The key prefix must match the environment
- Key prefix
- trnt_test_...
- Use
- Forced verdicts and CI
3. Declare the baseline and call the model
The baseline holds rules shared across governed work. Declare it once, then use the provider request shape you already know.
Governed provider call
Both paths set the same baseline and return the same result model.
- Python
- TypeScript
from trinitite import Trinitite
tr = Trinitite()
tr.govern(
frameworks=["soc2"],
mode="enforce",
)
response = tr.client(
"openai",
credential="cred_openai_prod",
).chat.completions.create(
model="gpt-4o",
messages=[{
"role": "user",
"content": "Refund order 4821.",
}],
)
result = tr.result(response)
import { Trinitite } from "@trinitite/sdk";
const tr = new Trinitite();
await tr.govern({
frameworks: ["soc2"],
mode: "enforce",
});
const response = await tr.client("openai", {
credential: "cred_openai_prod",
}).chat.completions.create({
model: "gpt-4o",
messages: [{
role: "user",
content: "Refund order 4821.",
}],
});
const result = tr.result(response);
- verdict
- passed
- violations
- []
- receipt
- dlir_01J7FIRSTCALL
The verdict drives the app path. The receipt records the decision.
Guarded request route
Current step: dlir_ receipt. Records the decision.
- 1Your codeThe request you already make
- 2SDKRoutes the call
- 3GuardianChecks the request
- 4Model or toolHandles the allowed call
- 5Result: passedNames the outcome
- 6dlir_ receiptRecords the decision
The wrapped client returns a fully materialized response. Provider token streaming is not part of this onboarding contract.
4. Handle every verdict
The verdict drives the app path. Other fields help people inspect, improve, and verify the decision.
Handle the complete result
- Python
- TypeScript
if result.verdict == "passed":
use(result.body)
elif result.verdict == "corrected":
use(result.body)
record(result.diff)
elif result.verdict == "blocked":
show_safe_fallback()
elif result.verdict == "masked":
keep_tokens_outside_trust_boundary()
elif result.verdict == "hitl":
queue_for_review()
else:
follow_error_policy()
trace = result.explain()
verification = (
result.receipt.verify()
if result.receipt and result.receipt.get("id")
else None
)
switch (result.verdict) {
case "passed":
case "corrected":
use(result.body);
break;
case "blocked":
showSafeFallback();
break;
case "masked":
keepTokensOutsideTrustBoundary();
break;
case "hitl":
queueForReview();
break;
default:
followErrorPolicy();
}
const trace = await result.explain();
const verification = result.receipt
? await result.receipt.verify()
: null;
Fields such as risk, flow_id, and receipt are optional. Check them before
use. Call explain() when a person needs the structured decision trace.
5. Test every branch
Forced verdicts make CI repeatable. They work only in development and test environments. Production rejects them before network I/O.
Test the blocked path
Exercise your own fallback without hoping a prompt triggers it.
- Python
- TypeScript
test_tr = Trinitite(env="test")
test_tr.govern(mode="enforce")
response = test_tr.client("openai").chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Test blocked."}],
force_verdict="blocked",
)
assert test_tr.result(response).verdict == "blocked"
const testTr = new Trinitite({ env: "test" });
await testTr.govern({ mode: "enforce" });
const response = await testTr.client("openai")
.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Test blocked." }],
force_verdict: "blocked",
});
expect(testTr.result(response).verdict).toBe("blocked");
Verdict test bench
Choose a synthetic verdict to exercise that Result branch with a trnt_test_ key.
Selected verdict: Blocked
The request did not pass the check.
Handle the blocked branch in your app.
Result {
verdict: "blocked"
forced: true
output
diff
violations
compliance
risk
receipt_id: "dlir_…"
}ForcedVerdictInProdError, request refusedKeep building
- SDK concepts explains baselines, scopes, assets, and result paths.
- Verdicts and modes maps each verdict to an app action.
- Evals onboarding turns real behavior into repeatable tests.
- The closed loop connects governed traffic, improvement, and gates.