Skip to main content
The wrappers patch the supplied client instance’s create method, preserve its return value, and emit one nozle.track() event when provider usage metadata is available. They capture model, input tokens, output tokens, latency, and an optional feature tag. Prompt and completion content are not inspected or sent.

OpenAI

OpenAI streaming

The wrapper reads usage from stream chunks. Request usage in the stream so a final usage-bearing chunk is available:
Tracking is attempted after the stream finishes.

Anthropic

For Anthropic streams, the wrapper reads input usage from message_start and output usage from message_delta events.

WrapOptions

Event properties

Cost calculation remains server-side. Configure the Feature and model cost rules to interpret these raw values.

Delivery behavior

The wrapper starts tracking without awaiting it so billing telemetry does not delay the provider response. It also relies on nozle.track() subscription resolution when no explicit subscription can be supplied through WrapOptions. For workflows requiring durable delivery, explicit transaction IDs, or strict error handling, track manually through your queue instead of relying on the wrapper.