CalmLens Python SDK
Server-side Python SDK for CalmLens content moderation, storage and CDN delivery.
It requires Python 3.10 or later, has no runtime dependencies and is fully typed (py.typed, checked with mypy --strict).
Install
python -m pip install calmlens
Quick start
Create an API key and copy your project ID as described in Authentication. Keep both on your server.
from calmlens import CalmLensServerClient
# Reads CALMLENS_API_KEY and CALMLENS_PROJECT_ID from the environment when not passed.
client = CalmLensServerClient()
asset = client.text.classify(text="Great photo!", external_id="comment-42")
if asset["classification"]["moderation"]["status"] == "allowed":
print("Allowed: safe to show")
with open("photo.jpg", "rb") as file: # streamed, not read into memory
queued = client.assets.create(name="photo.jpg", content={"data": file, "type": "image/jpeg"})
decided = client.assets.wait_for_decision(asset_id=queued["id"], timeout=30)
Methods take snake_case keyword arguments, or one options dict with the API's camelCase keys
(client.assets.retrieve({"assetId": "..."})). Responses are plain dicts with the API's camelCase
field names, typed as TypedDicts in calmlens.types.
assets.create queues processing; assets.classify and text.classify wait for the decision.
Act on classification.moderation.status:
| Status | What to do |
|---|---|
pending |
Moderation hasn't decided yet: wait, poll or handle a webhook. |
allowed |
Show the content. |
limited |
Show it with reduced reach: keep it out of recommendations and notifications. |
age-restricted |
Show it only to viewers your app has age-checked. |
blocked |
Don't show it. The content is kept for review. |
purged |
Don't show it. The stored content has been deleted. |
Treat a status you don't recognise, and a failed request, as not allowed.
What you can do
- Moderate text, images, audio and video and read the classification report.
- Stream uploads, including multipart uploads and uploads from a URL.
- Moderate replies with their conversation.
- Sign upload tokens for upload presets used from browsers.
- Manage assets: list, search, update, move, retry, record reviewer decisions, explain decisions and delete content.
- Organise assets in folders and compare uploads with hash lists.
- Deliver content through the CDN with lenses and transforms, signed URLs and viewer claims.
- Verify and parse webhooks from Flask, Django or FastAPI, or poll the events feed.
- Handle errors with stable error codes, and rely on safe retries and idempotency keys.
- Configure the client: timeouts, proxies,
connection reuse across threads and forked workers, and use from
asyncio.
Testing
MockCalmLensServerClient from calmlens.testing is the real client with an in-memory API behind it,
for offline tests. See Python testing.
Command-line tool
Use the standalone CalmLens CLI to forward signed webhook events to your machine and trigger test uploads.
Links
Metadata
Release files for calmlens 0.18.3
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 |
|---|---|---|---|---|
| calmlens-0.18.3.tar.gz | 108.0 kB | With provenance | Details for calmlens-0.18.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| calmlens-0.18.3-py3-none-any.whl | Python 3 | none | any | Details for calmlens-0.18.3-py3-none-any.whl |
Total release size: 192.2 kB
Release files / calmlens-0.18.3.tar.gz
| Download URL | calmlens-0.18.3.tar.gz |
|---|---|
| Size | 108.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da31eafef8a205798a331cfa3c87a1db96287fc4e5d830d8e0f295307a323096
|
|
BLAKE2b-256 checksum How to use checksums |
bf3094a18a8cdea15e76c98e6052edb3953e89ca6a1dc880602e8b0fc17dbb99
|
| 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 3, 2026.
Transparency logRelease files / calmlens-0.18.3-py3-none-any.whl
| Download URL | calmlens-0.18.3-py3-none-any.whl |
|---|---|
| Size | 84.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5ac863422ac19c5d3bba598b32a6fd986c6f057167a77653999e8a216900f15
|
|
BLAKE2b-256 checksum How to use checksums |
688c3068450190566faf4cc7c45d0e8a58ebdc501a53c7dc6d39537042321289
|
| 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 3, 2026.
Transparency logSecurity for calmlens 0.18.3
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 2 files in this release have been uploaded with provenance metadata.
Attestation for calmlens-0.18.3.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 3, 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.