squadem.ai
GitHub

Developers & SDK

One line. Every request protected.

The squadem SDK monkey-patches your HTTP network driver so every outbound API call to any LLM is intercepted at the source. PII is masked, messy prompts are compressed to save tokens, and the request leaves clean. When the response comes back, robotic AI language is rewritten to sound human, and your original data is restored. No proxy servers, no config files, no infrastructure changes.

One-line install

Drop a single import into your app. The SDK monkey-patches your HTTP client at the network layer, so every outbound request is intercepted before it leaves your process.

Zero data exposure

PII is masked locally before the request hits any external API. Your real data never touches a third-party server. Restoration happens on the response, client-side only.

Saves tokens & cost

The prompter compresses and restructures your text before it reaches the LLM. Cleaner input means fewer tokens, faster responses, and lower API bills.

Works with any LLM

OpenAI, Anthropic, Mistral, Gemini, local Ollama, or your own fine-tuned model. The SDK sits between your code and the network, so it works with any HTTP-based AI provider.

Supported PII Tags

The SDK detects these entity types automatically using on-device AI. Each match is replaced with a numbered token like {{NAME_1}} before the request leaves your process.

Regex-detected (structured formats)

EMAILjohn@acme.com→ {{EMAIL_1}}
PHONE+1 555-123-4567→ {{PHONE_1}}
SSN412-55-7890→ {{SSN_1}}
CREDIT_CARD4111 1111 1111 1111→ {{CREDIT_CARD_1}}
CURRENCY$85,000→ {{CURRENCY_1}}
DOB03/15/1990→ {{DOB_1}}
IP192.168.1.1→ {{IP_1}}
IBANDE89 3704 0044 ...→ {{IBAN_1}}
PASSPORTAB1234567→ {{PASSPORT_1}}

AI-detected (on-device model)

NAMESarah Parker→ {{NAME_1}}
ADDRESS742 Evergreen Terrace→ {{ADDRESS_1}}
ORGAcme Corp→ {{ORG_1}}
URLacme.com/dashboard→ {{URL_1}}
IDEMP-84921→ {{ID_1}}
USERNAME@sarahp→ {{USERNAME_1}}
DATElast Tuesday→ {{DATE_1}}

Quick Start

Install

npm install @squadem/sdk

Protect an OpenAI call

import { squadem } from "@squadem/sdk";

// One line — patches fetch & axios globally
squadem.init({ prompt: true, humanize: true });

// Use OpenAI normally — the SDK handles the rest
const response = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [
    {
      role: "user",
      content: "Summarize the contract for John Smith, SSN 412-55-7890"
    }
  ]
});

// What actually left your machine:
// "Summarize the contract for {{NAME_1}}, SSN {{SSN_1}}"
//
// What the LLM responded with:
// "The contract for {{NAME_1}} (SSN: {{SSN_1}}) outlines the following..."
//
// What you see in your code (humanized + restored):
// "The contract for John Smith (SSN: 412-55-7890) covers these terms..."

Works with Anthropic too

import Anthropic from "@anthropic-ai/sdk";
import { squadem } from "@squadem/sdk";

squadem.init();

const anthropic = new Anthropic();
const msg = await anthropic.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [
    {
      role: "user",
      content: "Draft an NDA between Alice Johnson (alice@acme.com) and Bob Lee"
    }
  ]
});

// Sent to Anthropic:
// "Draft an NDA between {{NAME_1}} ({{EMAIL_1}}) and {{NAME_2}}"
//
// Returned to your code:
// Full NDA with real names and emails restored

Express middleware

import express from "express";
import { squadem } from "@squadem/sdk";

const app = express();

// Protect every route that talks to an LLM
app.use(squadem.middleware());

app.post("/api/chat", async (req, res) => {
  // req.body.message is already masked
  const reply = await callAnyLLM(req.body.message);
  // res.json sends the restored version to the client
  res.json({ reply });
});

Python — same idea

import squadem
from openai import OpenAI

squadem.init()  # patches requests & httpx

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Send the invoice to david@company.io, amount $42,500"}
    ]
)

# Sent to OpenAI:
# "Send the invoice to {{EMAIL_1}}, amount {{CURRENCY_1}}"
#
# Returned to your code:
# Real email and amount restored seamlessly

Full round-trip: anonymize → compress → LLM → humanize → restore

import { squadem } from "@squadem/sdk";

squadem.init({
  anonymize: true,   // mask PII before it leaves
  prompt: true,      // compress & restructure to save tokens
  humanize: true,    // rewrite AI responses to sound human
});

// Step 1 — You write a messy prompt with real data
const prompt = `Hey can you please write a follow-up email to Sarah Parker
  her email is sarah@delta.io and its about the $85,000 deal
  we discussed last week, make it professional`;

// Step 2 — Anonymized + compressed (what the LLM actually receives)
// "Write professional follow-up email to {{NAME_1}} ({{EMAIL_1}})
//  re: {{CURRENCY_1}} deal discussed last week"
//
// 52 tokens → 24 tokens (54% saved)

const reply = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: prompt }]
});

// Step 3 — Raw LLM output (robotic, with tokens)
// "Dear {{NAME_1}}, I hope this message finds you well. I am writing to
//  follow up regarding the {{CURRENCY_1}} deal we discussed previously..."
//
// Step 4 — What your code gets back (humanized + PII restored)
// "Hi Sarah, Just circling back on the $85,000 deal we talked about..."

How it works

1

Intercept

The SDK patches your HTTP client (fetch, axios, requests, httpx) at the network driver level. No proxy, no sidecar.

2

Detect & mask

The on-device AI model scans for PII. Names, emails, phones, SSNs, credit cards, and more are replaced with safe tokens.

3

Compress

The prompter restructures your text into clean, concise instructions. Fewer tokens in, lower cost, better LLM output.

4

Forward

The sanitized, compressed request reaches the LLM provider. They see clean tokens, not your data or your rambling.

5

Humanize

When the response arrives, the on-device humanizer model rewrites robotic AI language into natural, human-sounding text.

6

Restore

The SDK swaps the tokens back to the original values. Your code sees natural, human text with real data, as if nothing happened.

Ready to protect your users?

Star the repo, open an issue, or jump straight into the docs.