Getting Started

Installation

Install Tork for Python or JavaScript to add AI governance to your applications. Tork ships two different packages — decide which one you want before you run an install command.

Two packages — pick deliberately

tork-governance (PyPI and npm) is the on-device package installed on this page. Its entry class is Tork. tork-governance makes the governance decision on your machine. PII detection, redaction and the returned verdict are computed on-device. With no API key it makes zero network calls: prompts, completions and detected PII values never leave the machine, and nothing appears in your dashboard.

@torknetwork/sdk (npm, v2.0.0) is the cloud package. Its entry class is TorkClient. It sends your content to Tork, Tork makes the decision server-side, and the receipt is written to your dashboard as capture_mode=cloud attested_by=tork. Both families can populate a dashboard; this is the one whose row records a decision Tork executed rather than a claim you attested.

TorkClient and AsyncTorkClient do not exist in tork-governance. Importing them after a tork-governance install is an ImportError in Python and undefined in JavaScript.

Local governance is free and unlimited — decisions made on your own machine are never metered. Evidence is what is metered: attestations, receipts and anchoring.

Python Installation — on-device (tork-governance)

Installs the on-device package. It governs locally and produces a local result; it does not populate your dashboard. The import root is tork_governance, not tork.

bash
# Install the on-device package
pip install tork-governance

# Verify installation
python -c "import tork_governance; print(tork_governance.__version__)"
Python 3.10 or higher required
govern() is synchronous — the decision is computed locally, so there is no network call to await
Type hints included for IDE autocomplete

JavaScript / TypeScript Installation — on-device (tork-governance)

Installs the on-device package. It governs locally and produces a local result; it does not populate your dashboard. Import { Tork } — this package has never exported TorkClient.

bash
# Using npm
npm install tork-governance

# Using yarn
yarn add tork-governance

# Using pnpm
pnpm add tork-governance
Node.js 18+ or modern browsers
Full TypeScript support with type definitions
ESM and CommonJS compatible

Verify Installation

Test the on-device install by governing a line of text. There is no API health check to run here — with no API key this makes zero network calls, so a successful result proves the package works locally, not that you can reach Tork.

python
from tork_governance import Tork

tork = Tork()

result = tork.govern("Check this text for PII: john@example.com")

print(result.action)              # GovernanceAction.REDACT
print(result.output)              # "Check this text for PII: [EMAIL_REDACTED]"
print(result.receipt.receipt_id)  # "rcpt_..." — a LOCAL receipt, not in your dashboard
javascript
import { Tork } from 'tork-governance';

const tork = new Tork();

// govern() is synchronous — there is no network call to await.
const result = tork.govern('Check this text for PII: john@example.com');

console.log(result.action);            // "redact"
console.log(result.output);            // "Check this text for PII: [EMAIL_REDACTED]"
console.log(result.receipt.receiptId); // "rcpt_..." — a LOCAL receipt, not in your dashboard

The Python result is a dataclass — read fields with result.action, not result['action']. The returned fields are action, output, pii, receipt and report. There is no redacted field — the governed text is in output.

Reporting On-Device Decisions to Your Dashboard

Supply an API key and the SDK additionally reports a metadata-only attestation of each decision — the action taken, PII type labels and counts, a risk classification, policy labels and a salted fingerprint. It never sends input text, output text or PII values. The decision itself is still made on-device and is never delayed or changed by reporting. Those attestations appear in your dashboard and are included in the daily on-chain anchor — each one recorded as a client attestation (capture_mode=edge, attested_by=client), a claim Tork recorded but did not execute and cannot independently verify. Requires tork-governance 0.24.0+ (PyPI) or 0.11.0+ (npm).

A decision reported by an on-device SDK is recorded as a client attestation (capture_mode=edge, attested_by=client): a claim Tork recorded but did not execute and cannot independently verify. A decision made by @torknetwork/sdk is recorded as capture_mode=cloud, attested_by=tork — Tork made that call itself. Both are equally immutable once anchored; they differ in what is immutable. A client attestation freezes your claim. A server-governed receipt freezes Tork's own decision.

Cloud Installation — @torknetwork/sdk

Install this instead if you want Tork to make the governance decision and write a receipt to your dashboard today. It sends your content to Tork. This is the package that exports TorkClient. It is npm-only — there is no PyPI equivalent, so Python users needing dashboard receipts should call the REST API directly.

bash
npm install @torknetwork/sdk
javascript
import { TorkClient } from '@torknetwork/sdk';

const client = new TorkClient({ apiKey: 'your_api_key' });

// Sends content to Tork; Tork decides server-side.
const result = await client.govern('Check this text for PII: john@example.com');

console.log(result.action);

A plain REST call with a Bearer token to https://tork.network/api/v1/govern is equally server-governed and works from any language.

Next Step: Configure your API key and environment. See Configuration.

Documentation

Learn to integrate TORK

Upgrade Plan

Current: free

Support

Get help from our team