> ## 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 @nozle-js/node

```bash theme={null}
npm install @nozle-js/node
```

Initialize the client:

```typescript theme={null}
import { Nozle } from '@nozle-js/node';

const nozle = new Nozle({
  apiKey: 'sk_live_...',
  baseUrl: 'https://api.nozle.app',
  eventsUrl: 'https://api.nozle.app',
  timeout: 10_000,
});
```

## NozleConfig props

* **apiKey** (`string`, required) -- Your secret key (`sk_`)
* **baseUrl** (`string`, default: `'http://localhost:8080'`) -- Nozle API URL
* **eventsUrl** (`string`, default: `'http://localhost:3000'`) -- Events ingestion URL (Lago)
* **timeout** (`number`, default: `10000`) -- Request timeout in ms

## 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.checkAndDeduct()` -- atomically check and deduct wallet credits

### LLM Auto-Capture

* `wrapOpenAI()` -- wrap OpenAI client for automatic token tracking
* `wrapAnthropic()` -- wrap Anthropic client for automatic token tracking

### Margin Intelligence

* `nozle.margin.summary()` / `byCustomer()` / `byMetric()` / `byPlan()` / `byModel()` / `trend()`

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