> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.nozle.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install and configure the Nozle Python SDK

```bash theme={null}
pip install nozle-sdk
```

Initialize:

```python theme={null}
from nozle import Nozle

nozle = Nozle(
    api_key="sk_live_...",
    base_url="https://api.nozle.app",
    events_url="https://api.nozle.app",
    timeout=10,   # seconds (default: 10)
)
```

## Parameters

* **api\_key** (`str`, required): Your secret key (`sk_`)
* **base\_url** (`str`, default: `"http://localhost:8080"`): Nozle API URL
* **events\_url** (`str`, default: `"http://localhost:3000"`): Events ingestion URL (Lago)
* **timeout** (`int`, default: `10`): Request timeout in seconds

## Available methods

### Core

* `nozle.track()` — send usage events
* `nozle.can()` — check entitlements
* `nozle.ping()` — health check

### Billing

* `nozle.plans()` — list available plans
* `nozle.checkout()` — create Stripe checkout session
* `nozle.subscribe()` — create a subscription

### Customers & Credits

* `nozle.customers.upsert()` — create or update a customer
* `nozle.check_and_deduct()` — atomically check and deduct wallet credits

### LLM Auto-Capture

* `wrap_openai()` — wrap OpenAI client for automatic token tracking
* `wrap_anthropic()` — wrap Anthropic client for automatic token tracking

### Margin Intelligence

* `nozle.margin.summary()` / `by_customer()` / `by_metric()` / `by_plan()` / `by_model()` / `trend()`

The Python SDK mirrors the Node.js SDK's API surface exactly.

<Warning>
  Use `sk_` (secret) keys only. This SDK is for server-side use.
</Warning>
