Skip to main content

Execution gateway and policy layer on top of KL Kernel Logic.

Project description

KL Exec Gateway

A small execution layer that lets you see and govern what an LLM actually does.

Most LLM calls are a black box: you send a prompt, something happens in between, and a result appears.

You don't see the steps, the decisions, or the filters.

KL Exec Gateway makes the entire process visible.

It runs each request through a deterministic pipeline:

LLM → Policy → Sanitization → Formatting → Trace

Every step recorded.
Local. Reproducible. Inspectable.


Try it in 10 seconds

pip install kl-exec-gateway
kl-gateway-web
# On first launch, the Browser will prompt you to enter your OpenAI API key.

Opens automatically at http://localhost:8787

You immediately see:

  • Live pipeline execution with animation
  • what you sent to the model
  • what the model returned
  • which rules were applied
  • what was removed or transformed
  • the final output
  • the full step-by-step trace

KL Exec Gateway Pipeline

Alternative: CLI mode

kl-gateway --key "sk-..."

Interactive terminal chat with full trace logging.


Examples

1. Allowed

A normal request flows through the entire pipeline:

hello

Result:

LLM → policy → sanitize → format → done

2. Denied after LLM (length limit)

tell me a love story

This usually produces a long answer that exceeds the default 500-character length policy:

LLM → policy (DENY_LENGTH) → done

3. Denied before LLM (forbidden pattern)

If a request contains a forbidden pattern (configured in the policy engine), it is blocked before the model is even called:

my secret code

Result:

policy (DENY_PATTERN) → done

The LLM step is skipped entirely.


Use cases

  • enforce policies on LLM output
  • remove or mask sensitive data
  • analyse model behaviour
  • build safe internal tools
  • reproduce responses
  • explain decisions to auditors or teams

Simple building blocks. All deterministic (except the LLM call).


Configuration

Default limits: 500 characters, basic pattern blocking.

To adjust:

  • Edit policy.config.json (policy limits)
  • Edit pipeline.config.json (pipeline steps, logging, trace)
  • Use templates: configs/production.config.json, configs/compliance-gdpr.config.json

Documentation


About the KL Execution Model

KL Exec Gateway is the first working demonstration of the KL execution model.

If you want to understand how the model works or extend it, the theory documentation describes the foundations.

docs/THEORY_ALIGNMENT.md


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

kl_exec_gateway-0.3.0.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

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

kl_exec_gateway-0.3.0-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file kl_exec_gateway-0.3.0.tar.gz.

File metadata

  • Download URL: kl_exec_gateway-0.3.0.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for kl_exec_gateway-0.3.0.tar.gz
Algorithm Hash digest
SHA256 da2db68018a1001e71d2d0f40bab93ef978adc3c078688e0bb8161c19c034397
MD5 bdd8a02dbe0181a4b7a7050417ab6e3f
BLAKE2b-256 64b069071305be1785a2c8957d926db1c3660042291fb895f9a0bbe2e2723682

See more details on using hashes here.

File details

Details for the file kl_exec_gateway-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kl_exec_gateway-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23ba9f44065c22a5384ff0199c10e79122cd154113ff8c07739406c4b054cf34
MD5 fd4bb60ddd6521406a913b82a6b79c16
BLAKE2b-256 acc0bb54f1887d4dc75f02151d9b04bf92f7103a63b0c4a6e227d16965e33e30

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