Commet SDK for Python - Billing and usage tracking for SaaS
Project description
Commet Python SDK
Billing and usage tracking for SaaS applications.
Installation
pip install commet-sdk
Quick start
from commet import Commet
commet = Commet(api_key="ck_xxx")
# Create a customer
commet.customers.create(email="user@example.com", external_id="user_123")
# Create a subscription
commet.subscriptions.create(external_id="user_123", plan_code="pro")
# Track usage
commet.usage.track(feature="api_calls", external_id="user_123")
# Track AI token usage
commet.usage.track(
feature="ai_generation",
external_id="user_123",
model="claude-sonnet-4-20250514",
input_tokens=1000,
output_tokens=500,
)
Customer context
Scope all operations to a customer to avoid repeating external_id:
customer = commet.customer("user_123")
customer.usage.track("api_calls")
customer.features.check("custom_branding")
customer.seats.add("editor", count=3)
customer.portal.get_url()
Webhook verification
from commet import Webhooks
webhooks = Webhooks()
payload = webhooks.verify_and_parse(
raw_body=request_body,
signature=request.headers["x-commet-signature"],
secret="whsec_xxx",
)
if payload is None:
raise ValueError("Invalid webhook signature")
if payload["event"] == "subscription.activated":
# handle activation
pass
Context manager
with Commet(api_key="ck_xxx") as commet:
commet.usage.track(feature="api_calls", external_id="user_123")
# connection pool is automatically closed
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commet_sdk-4.6.0.tar.gz.
File metadata
- Download URL: commet_sdk-4.6.0.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2945b5797d7beb20e11ae2126f0507096beffb01aac55381d5a47da04f3f9d48
|
|
| MD5 |
c61838c9566d03ec1f94b1f2c9f62621
|
|
| BLAKE2b-256 |
9bc09ae4100cbd8fc9ae8908d842c41964b8de070e85731a8cfe4cd793b76704
|
Provenance
The following attestation bundles were made for commet_sdk-4.6.0.tar.gz:
Publisher:
release.yml on commet-labs/commet-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commet_sdk-4.6.0.tar.gz -
Subject digest:
2945b5797d7beb20e11ae2126f0507096beffb01aac55381d5a47da04f3f9d48 - Sigstore transparency entry: 1629828079
- Sigstore integration time:
-
Permalink:
commet-labs/commet-python@ab44b763af804cd37962e8eb216046218b2c6b89 -
Branch / Tag:
refs/tags/v4.6.0 - Owner: https://github.com/commet-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ab44b763af804cd37962e8eb216046218b2c6b89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file commet_sdk-4.6.0-py3-none-any.whl.
File metadata
- Download URL: commet_sdk-4.6.0-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06335e4283d6cd679c207844a18106880d3cbecbe7f104a6ee5f8f134a3afae3
|
|
| MD5 |
edfeed68e46e6d5375d0e3e35eaaa61f
|
|
| BLAKE2b-256 |
2f57f1b597db71aee0957f9e634fd61702f4a138035b8d0561c432b41ad6d078
|
Provenance
The following attestation bundles were made for commet_sdk-4.6.0-py3-none-any.whl:
Publisher:
release.yml on commet-labs/commet-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commet_sdk-4.6.0-py3-none-any.whl -
Subject digest:
06335e4283d6cd679c207844a18106880d3cbecbe7f104a6ee5f8f134a3afae3 - Sigstore transparency entry: 1629828091
- Sigstore integration time:
-
Permalink:
commet-labs/commet-python@ab44b763af804cd37962e8eb216046218b2c6b89 -
Branch / Tag:
refs/tags/v4.6.0 - Owner: https://github.com/commet-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ab44b763af804cd37962e8eb216046218b2c6b89 -
Trigger Event:
push
-
Statement type: