@privedge/sdk
v0.4.1
Published
Privacy on the edge — drop-in AI proxy with automatic PII routing
Downloads
931
Maintainers
Readme
@privedge/sdk
Drop-in replacement for the OpenAI SDK with automatic PII detection and routing.
Install
npm install @privedge/sdkUsage
import Privedge from '@privedge/sdk'
const ai = new Privedge({
apiKey: 'your-privedge-api-key',
workerUrl: 'https://privedge-worker.workers.dev',
})
const res = await ai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Summarize this patient record...' }],
})
console.log(res.routed_to) // 'edge' | 'cloud'
console.log(res.pii_matches) // number of PII tokens detected
console.log(res.anonymized) // true if PII was redacted before the cloud callEvery request is inspected for PII automatically. The routing strategy (anonymize vs edge) is configured at the API key level on the Worker — not in the SDK.
Response fields
| Field | Type | Description |
|-------|------|-------------|
| routed_to | 'edge' \| 'cloud' | Where the request was sent |
| pii_matches | number | PII tokens detected |
| anonymized | boolean | Whether PII was redacted before the cloud call |
| choices | array | Standard OpenAI-compatible response |
Worker
The SDK talks to a self-hosted Privedge Worker running on Cloudflare.
License
MIT — privedge.io
