Embedded AI margin
control.
P402 Meter records cost per feature, per customer, per workflow. Track AI COGS, retry waste, context waste, and cost per accepted output.
Built on the P402 Meter surface. Parent product page: /developers.
AI cost lands on the wrong line of the P&L.
Provider invoices are a lump sum. Without per-feature and per-customer attribution, embedded AI cost shows up under infrastructure instead of cost of goods sold, and feature margin stays a guess.
- 01Create a P402 key.Sign in, generate a key. The key is returned once. P402 stores only a hash.
- 02Wrap the AI call once.Use the OpenAI-compatible endpoint or post a meter-only event from your backend. The call returns a normal completion plus an event id.
- 03Attach customer, feature, and workflow on the request.Owners are free-form within the documented vocabulary. The same event can roll up under customer, feature, workflow, and budget at once.
- 04Read margin numbers.Cost per feature, per customer, per accepted output, with retry and context waste. The rollup is available in the Meter dashboard and via the events API.
Meter economics, not content.
Margin numbers come from token counts and cost, not prompts. Prompt and response storage are off by default. Sensitive customer features can run under private gateway mode, where the inference stays in your environment and P402 records the economic event over a signed channel.
metadata_onlyOwner, cost, tokens, budget, policy, outcome, and evidence status. No prompts. No responses. Default.fingerprint_onlyAdds a hash fingerprint of prompt and response for dedup and replay protection. Content stays out.redacted_tracePrompt and response retained after a redaction pass for fields the tenant policy allows.private_gatewayYour environment hosts the inference, P402 records the economic event over a signed channel.full_traceOpt-in. Prompts and responses retained verbatim with the event. Requires explicit tenant policy.
Same metering layer, four shipped workflows.
Each vertical demo is a working surface on the same metering layer. Use them to see cost per feature, per customer, and per accepted output against a concrete workflow.
Margin numbers without a billing rewrite.
Wrap the AI call once. P402 attributes every token to a customer, feature, workflow, and budget. Cost per accepted output, retry waste, and context waste are surfaced on the same events your code already emits.
Same events feed finance.
The same metered events back the enterprise budget dashboard. Engineering works the margin lever, finance reads attribution and evidence from the same ledger.
What does embedded AI margin control mean here?+
Cost per feature, per customer, per workflow, and per accepted output recorded at the moment of each AI call. Margin equals price charged to the customer minus AI cost attributed to that customer. P402 Meter provides the cost side.
Does it require switching providers?+
No. P402 wraps OpenAI, Anthropic, Gemini, Bedrock, OpenRouter, and any HTTP-callable model. Existing provider relationships stay in place. Margin is computed against whichever provider served the call.
Does it require storing prompts?+
No. Default privacy mode is metadata-only. Owner, model, tokens, cost, budget, policy result, outcome, and evidence status are recorded. Prompts and responses stay out unless the tenant explicitly opts in.
How is retry waste measured?+
Tokens spent on retried calls that produced no new outcome are flagged on the event. Retry waste is rolled up per feature and per customer, so engineering can see which features carry retry tax.
How is context waste measured?+
Tokens spent on context that did not change the outcome of the call are flagged. The rollup shows which features carry context that does not earn its keep.
What is the cost per accepted output?+
Total AI cost for a feature, divided by the count of events with outcome accepted. The dashboard surfaces it per feature and per customer so margin work targets the right place.
Track margin per feature, not per invoice.
Wrap one AI call. The first metered event lands in the ledger and the feature, customer, and workflow rollups render with real numbers.