feature_not_found.
1. Bill tokens
- Create a metered Feature with the event code. In Usage → Meters → New, set Event code to the code your capture sends:
llm_tokensby default, or yourfeatureCode/X-Nozle-Feature-Code.- Method Sum, Value property
total_tokens, Expressionevent.properties.input_tokens + event.properties.output_tokens. The expression writes the sum intototal_tokensbefore the event is stored. - To charge more for output tokens, weight them in the expression, for example
event.properties.input_tokens + event.properties.output_tokens * 4, and price per weighted token. One event code maps to one Feature, so a weighted expression is how one event carries both prices. - To bill only one side, skip the expression and set Value property to
input_tokensoroutput_tokens. - A Feature with an expression cannot be used with product credits.
- Method Sum, Value property
- Charge for it on the plan. Add a usage charge for the Feature, for example package pricing per 1,000,000 tokens. Add an entitlement limit if you want
can()to stop customers at a limit. See plans. - Give each customer one active subscription. The usage event is billed to a subscription. Capture looks up the customer’s single active subscription and records nothing for a customer with none or several. Pass a subscription id when a customer has several. The LLM proxy looks it up before it calls the provider and refuses the call with
422 active_subscription_not_foundor422 active_subscription_ambiguous; sendX-Nozle-Subscriptionwhen a customer has several.
2. Record the cost of tokens and see margin
- Create a cost model from the AI tokens template (Usage → Cost models → New, cost path Detailed Cost Event). It creates the Cost Event Meter
ai_tokens(sum oftokens, filtered byprovider,modelandtype). Enter your rate for each token type: input, output, and optionally cached input, cache write and reasoning. - Link it to the usage Feature. Set Linked feature to your token Feature (for example
llm_tokens) and the composition to Detailed events only, then publish. With Linked feature set to none, each token cost event is still rated on its own meter and attributed to the customer, subscription and Feature of the usage event it points to, and counts in margin; the usage event itself stays uncosted withmissing_cost_composition. A cost event for another customer than its parent is uncosted asparent_customer_mismatch, and one whose parent never resolved asparent_attribution_failed. Cost events recorded before this behavior are not rated again by themselves: replay the parent usage event, then its cost events. Linking a Feature is still the way to get a composition and thecan()estimate. - One cost model per provider and model you use. The template’s conditions must equal the
providerandmodelvalues the capture sends (provideris the response format:openai,anthropicorgemini). A model without a matching rule is listed as uncosted withno_matching_cost_rule. - Turn on cost events in capture. Set
costMeterCode: "ai_tokens"(Node.js),cost_meter_code="ai_tokens"(Python) orCostMeterCode: "ai_tokens"(Go). Each response then also sends one cost event per token type, linked to its usage event. - Check for uncosted events in the cost intelligence report or the Uncosted queue after the first calls. See cost models.
can() to return an estimated cost and margin before work starts, also add Feature Event cost components on the token Feature, set the composition to Add both, and use a standard charge. Without them can() reports economics as not_configured.
3. Credits instead of invoices
Usage capture does not spend product credits. To deduct credits per call, make the Feature consumable (Count, or Sum on a property without an expression), give it a credit system rate, and callusage.track() with the token count after the LLM call instead of relying on capture. See credit usage tracking.