Skip to main content

Local LLM egress control for Python developers — prevents API keys, secrets, .env files, and sensitive payloads from being sent to LLM APIs

Project description

killswitch-ai

PyPI version Python License: MIT Tests

Local LLM egress control for Python developers. Stops API keys, secrets, .env files, and sensitive payloads before they reach OpenAI, Anthropic, or any LLM API — without leaving your machine.


Install

pip install killswitch-ai

With provider extras:

pip install "killswitch-ai[openai]"      # OpenAI
pip install "killswitch-ai[anthropic]"   # Anthropic
pip install "killswitch-ai[all]"         # Both

Quick start

One-liner

import killswitch
killswitch.install()

from openai import OpenAI
client = OpenAI()  # now protected — every request is scanned first

Explicit wrapper

from openai import OpenAI
from killswitch.openai import GuardedOpenAI

client = GuardedOpenAI(OpenAI())

Anthropic

from anthropic import Anthropic
from killswitch.anthropic import GuardedAnthropic

client = GuardedAnthropic(Anthropic())

Scan text directly

import killswitch

result = killswitch.scan("my API_KEY is sk-proj-abc123...")
for finding in result.findings:
    print(finding.severity, finding.description)

How it works

Your code  →  killswitch  →  LLM API
               ↓
           scan prompt
               ↓
         finding detected?
          ┌──────────────────────────────┐
          │  kill        →  raise error  │
          │  pause       →  ask you      │
          │  redact      →  [REDACTED]   │
          │  report_only →  log + allow  │
          └──────────────────────────────┘

Everything runs locally. No prompts, responses, file contents, or secret values leave your machine for inspection.


What gets detected

Layer Examples
Prohibited terms API_KEY, SECRET_KEY, CONFIDENTIAL, custom terms
Secret patterns OpenAI keys (sk-proj-…), Anthropic keys, AWS keys, GitHub tokens, Stripe keys, private key PEM blocks, JWT tokens, database URLs
Entropy detection Long random-looking strings that might be secrets
Sensitive file paths .env, *.pem, id_rsa, credentials.json, kubeconfig
Structured payloads Recursively scans every field in nested JSON

Modes

Mode What happens
pause Stops and asks you what to do (default)
kill Blocks the request automatically
redact Replaces secrets with [REDACTED_X] and continues
report_only Allows the request but logs a finding

Change mode anytime:

killswitch mode kill
killswitch mode pause
killswitch mode redact
killswitch mode report-only

Set up

killswitch init

Runs an interactive wizard: choose a mode, pick data categories to protect, optionally enable weekly email summaries. Writes killswitch.yml to your project.

Then verify installation:

killswitch test

CLI

killswitch init                    # Interactive setup wizard
killswitch test                    # Verify the scanner is working
killswitch status                  # Show current mode and recent stats
killswitch scan "text to scan"     # Test the scanner on text
killswitch menu                    # Open the interactive report menu
killswitch mode kill               # Change active mode
killswitch logs --latest           # View latest session findings
killswitch event KAI-E-...         # Look up a specific event
killswitch finding KAI-F-...       # Look up a specific finding
killswitch report                  # Print the weekly summary
killswitch report --send           # Send weekly report by email
killswitch email --on              # Enable email reports
killswitch email --off             # Disable email reports

Configuration (killswitch.yml)

mode:
  default_action: pause            # kill | pause | redact | report_only

detection:
  prohibited_terms:
    - "API_KEY"
    - "SECRET_KEY"
    - "PRIVATE KEY"
    - "MY_CUSTOM_TERM"
  entropy_detection:
    enabled: true
    min_length: 24
    threshold: 4.2

actions:
  private_key: kill
  openai_key: kill
  anthropic_key: kill
  database_url: pause
  prohibited_term: pause
  high_entropy_string: report_only

logging:
  enabled: true
  log_dir: .killswitch
  store_raw_payloads: false        # never stores prompt text
  store_secret_values: false       # never stores secret values

email:
  enabled: false
  address: ""
  frequency: weekly

Local logs

Every scan writes an audit event to .killswitch/sessions/. Raw prompts and secret values are never stored.

Stored: event ID, timestamp, provider, operation, decision (blocked / allowed / redacted), finding type, severity, recommendations.

Never stored: prompt text, LLM responses, secret values, API keys, source code, file contents.


Privacy

  • All scanning runs locally — nothing leaves your machine for inspection
  • No prompts or responses are uploaded
  • No secret values are stored in logs or telemetry
  • Anonymous opt-in telemetry reports only aggregate counts (scans, blocks, finding categories) — disabled by default

Links


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

killswitch_ai-0.1.5.tar.gz (54.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

killswitch_ai-0.1.5-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

Details for the file killswitch_ai-0.1.5.tar.gz.

File metadata

  • Download URL: killswitch_ai-0.1.5.tar.gz
  • Upload date:
  • Size: 54.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for killswitch_ai-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5dbd4330c98803a707614da719dde61b3f4ef8fbbfeb691ad6c42a312dff889c
MD5 b63209d73abb95e66d22e0e8be0b72f0
BLAKE2b-256 4709b4f031fb8079ec57ff5dc0db721d1456ad597fd66b5b2c53bc5b66801738

See more details on using hashes here.

File details

Details for the file killswitch_ai-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: killswitch_ai-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 52.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for killswitch_ai-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a03f17bc17dcb3f7e0e362ea72657d4be5612e5094bcf12cc6006a2637c32460
MD5 8eac4f94e87ac03e80fcabed7c8b4230
BLAKE2b-256 29684dae728b5c5852a6a94c44c7d1ac8d1025fa8c03585f5d76f316a59f46ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page