Getting Started with Tork
Get up and running with Tork in 5 minutes. This guide walks you through account setup, API key creation, SDK installation, and making your first API call.
Prerequisites
Before you begin, make sure you have:
- A Tork account (we'll create one in Step 1)
- Python 3.10+ or Node.js 18+ installed
- A terminal or command prompt
Create Your Account
Sign up for a free Tork account to get started. The free tier includes 1,000 API calls per month—plenty to explore and test the platform.
OAuth Support
Get Your API Key
After signing up, you'll be automatically redirected to your dashboard where your first API key is ready. You can also create additional keys from the API Keys page.
Finding Your API Key
- Go to your Dashboard → API Keys
- Your default API key will be shown (prefix only for security)
- Click "Create New Key" if you need additional keys
- Copy the full key when shown—it won't be displayed again
Keep Your API Key Secret
Install the SDK
This installs tork-governance, the on-device package, whose entry class is Tork. It governs on your machine and returns a local result; the API key from step 2 is not used by it, and its decisions do not appear in your dashboard. Step 4 shows both paths side by side.
pip install tork-governanceDirect API Access
Make Your First API Call
Now let's make your first governance check. There are two ways to do it, and they differ in where the decision is made and whether it leaves evidence.
On-device vs server-governed
The Python and JavaScript blocks below use tork-governance and decide on your machine. 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.
The cURL block and @torknetwork/sdk send your content to Tork, which decides server-side and writes a receipt to your dashboard as capture_mode=cloud attested_by=tork. Both families can populate a dashboard; that is the one whose row records a decision Tork executed rather than a claim you attested.
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 — on-device (tork-governance)
from tork_governance import Tork
# No API key: the decision is made on this machine and nothing
# is sent anywhere. This is free and unlimited.
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 dashboardJavaScript — on-device (tork-governance)
import { Tork } from 'tork-governance';
// No API key: the decision is made on this machine and nothing
// is sent anywhere. This is free and unlimited.
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 dashboardcURL — server-governed (Tork decides)
curl -X POST https://tork.network/api/v1/govern \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"content": "Check this text for PII: john@example.com"
}'Understand the Response
The /v1/govern REST endpoint — the cURL path above — returns a JSON response with the governance decision and details about any detected PII:
{
"action": "redact",
"redacted": "Check this text for PII: [EMAIL]",
"original": "Check this text for PII: john@example.com",
"pii_detected": [
{
"type": "email",
"value": "john@example.com",
"position": { "start": 27, "end": 43 },
"confidence": 0.99
}
],
"policy_applied": "default",
"processing_time_ms": 45,
"request_id": "req_abc123"
}Response Fields
These are the REST response fields. The on-device SDK returns a different shape: action, output, pii, receipt and report, with the governed text in output rather than a redacted field. In Python that result is a dataclass, so read it with result.action, not result['action'].
| Field | Type | Description |
|---|---|---|
| action | string | allow, redact, or deny |
| redacted | string | The text with PII replaced by placeholders |
| pii_detected | array | List of detected PII with types and positions |
| policy_applied | string | Name of the governance policy that was applied |
| processing_time_ms | number | Processing time in milliseconds |
You're Ready!
Using Environment Variables
For production use, store your API key in an environment variable instead of hardcoding it. Note what the key does and does not change here: the on-device SDK still makes every decision locally with or without one. A key only governs whether a metadata-only attestation is reported.
import os
from tork_governance import Tork
# No key: local governance only, nothing reported.
tork = Tork()
# With a key: the decision is still made locally; an attestation
# of it is reported. Reads TORK_API_KEY from the environment.
tork = Tork(api_key=os.environ.get('TORK_API_KEY'))Attestation reporting status
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.
Next Steps
Now that you've made your first API call, explore these resources to learn more:
Common Issues
401 Unauthorized
Only the server-governed paths (cURL / @torknetwork/sdk) can return this — the on-device SDK never authenticates without a key. Check that:
- The API key is correctly copied (no extra spaces)
- The key hasn't been revoked in your dashboard
- You're using
Bearerprefix in the Authorization header
429 Rate Limited
You've exceeded your plan's API call limit. Options:
- Wait for your billing period to reset
- Upgrade your plan for higher limits
- Implement caching to reduce API calls
Connection Errors
If you're having trouble connecting:
- Check your internet connection
- Verify you're using HTTPS (not HTTP)
- Check tork.network for current availability