Skip to main content

siftfy-python

Official Python client for the Siftfy spam-classification API. POST text, get a calibrated spam probability back. One round-trip, no queues, no models to host.

PyPI version Python versions CI License: MIT

Requirements

Siftfy supports Python 3.9 and newer.

Install

pip install siftfy

Quick start

from siftfy import Siftfy

client = Siftfy(api_key="sk_live_...")

result = client.predict("Win a free iPad — click here!")
print(result.spam_probability)  # 0.97
print(result.likelihood)        # "high"

Get an API key at siftfy.io — the free tier covers 10,000 requests/month at no cost.

Runnable examples

Use these when wiring Siftfy into a real form, signup flow, or moderation queue:

Async

import asyncio
from siftfy import AsyncSiftfy

async def main() -> None:
    async with AsyncSiftfy(api_key="sk_live_...") as client:
        result = await client.predict("hello, world")
        print(result.spam_probability)

asyncio.run(main())

Calibrated probabilities

Every spam_probability is a calibrated value between 0 and 1 — at 0.7, roughly 70% of inputs with that score are actually spam. Pick a threshold appropriate to your use case (a help-desk form tolerates more false positives than a marketplace listing); the same model serves both.

The likelihood field is a coarse bucket ("low", "medium", "high") derived from the probability. Handy for quick branches, but for production decisions thread on the raw probability and your own threshold.

Errors

from siftfy import (
    Siftfy,
    AuthenticationError,  # 401 — bad / revoked key
    RateLimitError,       # 429 — over your tier limit; .retry_after available
    APIError,             # any other 4xx/5xx
    SiftfyError,          # network / request transport errors
)

try:
    result = client.predict(text)
except RateLimitError as e:
    sleep_for = e.retry_after or 1.0
    ...
except AuthenticationError:
    ...
except APIError as e:
    log(f"siftfy error {e.status_code}: {e} (request_id={e.request_id})")

The client retries idempotent failures (HTTP 408 / 429 / 5xx, network errors) with exponential backoff and jitter, honouring Retry-After when present. Tune with max_retries=N (default 2; set 0 to disable).

Configuration

client = Siftfy(
    api_key="sk_live_...",
    base_url="https://api.siftfy.io",  # override for self-hosted / staging
    timeout=10.0,                       # seconds, applied per attempt
    max_retries=2,                      # 0 disables retries
)

You can also pass your own httpx.Client (or httpx.AsyncClient for the async client) via http_client=... if you want connection pooling, custom transports, or to share a client across services.

Development

python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -e ".[dev]"

ruff check src tests
mypy src
pytest -q
python -m build

Support and security

Use GitHub Issues for SDK bugs and feature requests. Do not open public issues for suspected vulnerabilities; report them privately using the process in SECURITY.md.

Resources

License

MIT — see LICENSE.

Metadata

Release files for siftfy 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for siftfy 0.1.2
File Size Uploaded
siftfy-0.1.2.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for siftfy 0.1.2
File Interpreter ABI Platform
siftfy-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / siftfy-0.1.2.tar.gz

Download URL siftfy-0.1.2.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc23d9e1fa7e449563b58af2755b9150e35eae7f6fa3e2cb49144a10dae198d0
BLAKE2b-256 checksum
How to use checksums
efa0535a3812610848097bdc6a15f609cb176c457bfcebaf84f8a81aa53b97b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 May 15, 2026.

Transparency log

Release files / siftfy-0.1.2-py3-none-any.whl

Download URL siftfy-0.1.2-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a5d8b7491b95316de3ab7386f1d108646faaff900cbb2a68a008da754c117f3
BLAKE2b-256 checksum
How to use checksums
bb7dccef877fedb1f1d3df1553c97b6a6cb17f00ba4e075585fac94e37252de3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 May 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page