Commet
  • Pricing
Log InTry out
Introduction

Quickstart

Integrate with PythonIntegrate with FlaskIntegrate with FastAPIIntegrate with Django

Learn

Resources

SDK ReferenceError HandlingTestingCLI

Plugins

Better Auth
DocumentationKnowledge BaseBuild with AIAPI ReferenceWebhooks

Integrate with Python

Install and configure the Commet Python SDK.

Install

pip install commet-sdk
uv add commet-sdk
poetry add commet-sdk

Configure

.env
COMMET_API_KEY=ck_sandbox_xxx
commet_client.py
import os
from commet import Commet

commet = Commet(
    api_key=os.environ["COMMET_API_KEY"],
    environment="sandbox",
)

Create Customer and Subscribe

customers.create is idempotent — if a customer with the same external_id exists, it returns the existing record.

response = commet.customers.create(
    email="user@example.com",
    external_id="user_123",
)

subscription = commet.subscriptions.create(
    external_id="user_123",
    plan_code="pro",
)

checkout_url = subscription.data["checkout_url"]

The customer is redirected to checkout to complete payment.

Check Access

sub = commet.subscriptions.get("user_123")
status = sub.data["status"]

access = commet.features.check(code="custom_branding", external_id="user_123")
allowed = access.data["allowed"]

Track Usage

commet.usage.track(
    external_id="user_123",
    feature="api_calls",
    value=1,
)

Usage is aggregated and billed at end of period.

Customer Context

Scope all operations 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)

Related

  • Flask
  • FastAPI
  • Django
  • SDK Reference

How is this guide?

Integrate with Bun

Add billing and payments to your Bun application.

Integrate with Flask

Add billing and payments to your Flask application.

On this page

Install
Configure
Create Customer and Subscribe
Check Access
Track Usage
Customer Context
Related