kalkan (Python)
A fast PII shield for Turkish text: masks personal data (national ID, IBAN, phone, card, names,
addresses, SGK numbers, IP, date of birth, …) before it reaches an LLM and restores it in the reply. Built for KVKK
(Turkey's GDPR counterpart). Written in Rust; about 8× faster than pure-Python regex solutions on
a single core, and mask_batch uses all cores with the GIL released.
Türkçe: Türkçe kişisel verileri LLM'e gitmeden maskeleyen, cevapta geri yükleyen KVKK motoru. Türkçe belgeler için README.tr.md.
Usage
pip install kalkan
import kalkan
k = kalkan.Kalkan(terms=["Proje Atlas"])
s = k.session() # one session per conversation
prompt = s.mask("Ayşe Kaya Hanım, TC 10000000146, Proje Atlas bütçesi")
# "[AD_SOYAD_1] Hanım, TC [TCKN_1], [OZEL_1] bütçesi"
reply = llm(prompt)
report = s.audit(reply) # did the model produce new PII?
if not report:
log.warning(report)
print(s.restore(reply))
# Streaming
stream = s.stream()
for chunk in llm_stream(prompt):
send(stream.push(chunk))
send(stream.finish())
# Batch anonymization: all cores, GIL released
clean = kalkan.Kalkan(strategy="label").mask_batch(millions_of_records)
start/end in detect() results are character indices: text[e.start:e.end] works directly.
The vault is available as a dict via s.vault and can be loaded in another process with import_vault.
Integrations
from kalkan.messages import mask_messages # OpenAI SDK, no dependencies
from kalkan.integrations.litellm import completion # pip install "kalkan[litellm]"
from kalkan.integrations.litellm import KalkanGuardrail # LiteLLM Proxy guardrail
from kalkan.integrations.langchain import with_kalkan # pip install "kalkan[langchain]"
All of them restore streaming replies, even when a placeholder is split across chunks.
Full documentation, limitations and benchmarks: github.com/CelkMehmett/kalkan.
kalkan is a helper, not a legal compliance guarantee. Detection is not 100%.
Metadata
Release files for kalkan 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kalkan-0.3.0.tar.gz | 88.1 kB | With provenance | Details for kalkan-0.3.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kalkan-0.3.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for kalkan-0.3.0-cp39-abi3-win_amd64.whl |
| kalkan-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for kalkan-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| kalkan-0.3.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for kalkan-0.3.0-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 1.0 MB
Release files / kalkan-0.3.0.tar.gz
| Download URL | kalkan-0.3.0.tar.gz |
|---|---|
| Size | 88.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
104076b1f8476a47d7ba37f4afc917c0ccadeff3c5d5da09fb12001f1db7b2a1
|
|
BLAKE2b-256 checksum How to use checksums |
008588d336243cea884dbd0a8c7a3d26698b40ab187133ff9683d754174165ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / kalkan-0.3.0-cp39-abi3-win_amd64.whl
| Download URL | kalkan-0.3.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 244.7 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1880fde660958e6dcffc82eeced83ec5d8fd596494924bd0f90e7daf931af134
|
|
BLAKE2b-256 checksum How to use checksums |
c00921b93ba67cb9d451729a14cf5671faeb19aa194498b4006074d0784e84bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / kalkan-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | kalkan-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 378.8 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cb14ff64980c6194a429bf8cedd10411a3023a9e73164bb420cb433866fff56d
|
|
BLAKE2b-256 checksum How to use checksums |
7657939773ffd6e4383ccaa7b70f7cdc5219fc310a0ffacd51610febf50eaa42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / kalkan-0.3.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | kalkan-0.3.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 331.4 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
023fe4ed4aeb6be40c999b96da74c46a5bde78439d2fd8845e125df96c8838c7
|
|
BLAKE2b-256 checksum How to use checksums |
564c499d6a8a9a3da692f270007470121b5e36b60d006f9c0eef9a5526e944ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for kalkan 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for kalkan-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.