Skip to content

nozle-dev/nozle-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nozle

Python SDK for usage tracking, margin intelligence, and entitlement checks.

Install

pip install nozle-sdk

Quick Start

from nozle import Nozle

client = Nozle(
    api_key="your-api-key",
    base_url="https://api.your-domain.com",
    events_url="https://events.your-domain.com",
)

# Track usage events
client.track("customer_123", "api_call", metadata={"model": "gpt-4", "tokens": 1500})

# Check feature entitlements
result = client.can("customer_123", "advanced_analytics")

# Margin intelligence
summary = client.margin.summary()
by_customer = client.margin.by_customer()
by_model = client.margin.by_model()
trend = client.margin.trend(granularity="day")

Margin Intelligence

The margin client exposes several views into your cost and revenue data:

client.margin.summary()                        # overall margin summary
client.margin.by_customer()                    # margin broken down by customer
client.margin.by_metric()                      # margin broken down by billable metric
client.margin.by_plan()                        # margin broken down by plan
client.margin.by_model()                       # margin broken down by AI model
client.margin.trend(granularity="day")         # margin trend over time

Plans & Checkout

# List available plans
plans = client.plans()

# Create checkout session (returns Stripe client_secret)
result = client.checkout("customer_123", "pro")
# result = { "client_secret": "...", "invoice_id": "...", "amount_cents": 2900, "currency": "USD" }

# With success URL
result = client.checkout("customer_123", "pro", success_url="https://example.com/done")

# Create subscription after payment
result = client.subscribe("customer_123", "pro")
# result = { "subscription_id": "...", "status": "active" }

Optional: OpenAI Integration

pip install nozle-sdk[openai]

License

AGPL-3.0-or-later

About

Nozle Python SDK — usage tracking, margin intelligence, and entitlement checks

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages