Skip to main content

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
customer = commet.customers.create(email="user@example.com")

# Create a subscription
commet.subscriptions.create(customer_id=customer.id, plan_code="pro")

# Track usage
commet.usage.track(
    feature_code="api_calls",
    customer_id=customer.id,
    value=1,
)

# Track AI token usage
commet.usage.track(
    feature_code="ai_generation",
    customer_id=customer.id,
    model="claude-sonnet-4-20250514",
    input_tokens=1000,
    output_tokens=500,
)

Offers and pricing Markets

SDK v8 exposes reusable Offers, country Market Groups, and selectable price_id variants:

market = commet.pricing.create_market_group(
    name="Argentina",
    country_codes=["AR"],
)

offer = commet.offers.create(
    name="First three months at 25% off",
    purpose="promotional",
    plan_price_ids=["pp_monthly"],
    phases=[{"type": "percentage", "percentage": 2500, "duration_cycles": 3}],
)

Promo Codes reference Promotional Offers. Omitting price_id during subscription creation keeps normal default-price resolution.

Quota

# Add to the quota balance (count defaults to 1)
commet.quota.add(feature_code="storage", customer_id="cus_123")

# Set the quota balance to an exact value
commet.quota.set(feature_code="storage", count=10, customer_id="cus_123")

# Remove from the quota balance (count defaults to 1)
commet.quota.remove(feature_code="storage", customer_id="cus_123")

# Read a single allowance
commet.quota.get(feature_code="storage", customer_id="cus_123")

# Read every allowance for a customer
commet.quota.get_all(customer_id="cus_123")

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_code="api_calls",
        customer_id="cus_123",
        value=1,
    )
# connection pool is automatically closed

License

MIT

Metadata

Release files for commet-sdk 8.0.1

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

Source distribution (sdist)

Source distribution for commet-sdk 8.0.1
File Size Uploaded Provenance Actions
commet_sdk-8.0.1.tar.gz 71.5 kB With provenance Details for commet_sdk-8.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for commet-sdk 8.0.1
File Interpreter ABI Platform Actions
commet_sdk-8.0.1-py3-none-any.whl Python 3 none any Details for commet_sdk-8.0.1-py3-none-any.whl

Total release size: 159.2 kB

Release files / commet_sdk-8.0.1.tar.gz

Download URL commet_sdk-8.0.1.tar.gz
Size 71.5 kB
Tags Source
SHA-256 checksum
How to use checksums
20bba74c6b4617731971f55ae320ae12c4817e9f53b3f5845b04de8f0547ae7f
BLAKE2b-256 checksum
How to use checksums
d3ef0a71b3e7b303a1917d0adfc6bd6bf6c66e07e5051c92fa5c9b0e71557a13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 29, 2026.

Transparency log

Release files / commet_sdk-8.0.1-py3-none-any.whl

Download URL commet_sdk-8.0.1-py3-none-any.whl
Size 87.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b10e1929fb1305ef2d957002d0c65d1b6c164923fa5721f3bb452eed4b8987cf
BLAKE2b-256 checksum
How to use checksums
cdf111ea7a94e0465b1845a61988f092038a6d5810345d535674552f9ff9be1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 29, 2026.

Transparency log

Security for commet-sdk 8.0.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for commet_sdk-8.0.1.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 Jul 29, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

8.0.1 This release

2 release files Full provenance

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