Build AI features with
cost ownership.
P402 gives developers an OpenAI-compatible meter for AI usage, margin, workflow attribution, outcomes, and optional settlement.
Metadata-only by default. No prompt storage required. Settlement is optional.
AI cost is invisible until it bites margin.
Engineering ships AI features without per-call attribution. Finance sees the invoice. The team cannot tell which feature, which customer, which workflow, or which retry caused the cost. P402 records that attribution at the moment of the call.
- 01Create a P402 key.Sign in, generate the key. The key returns exactly once.
- 02Wrap your AI call through the OpenAI-compatible endpoint.Point baseURL to https://p402.io/v1 and use the existing OpenAI SDK pattern.
- 03Attach workflow_id, customer_id, feature_id metadata.Owner taxonomy is indexed on every event. Filter the ledger by any dimension.
- 04Report the outcome. View the event in the spend ledger.Send accepted, revised, escalated, or failed. The event lands in the dashboard with cost and attribution attached.
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.P402_API_KEY,
baseURL: 'https://p402.io/v1',
});
const completion = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Summarize Q3 revenue.' }],
// Attribution travels with the call.
metadata: {
workflow_id: 'finance.summary',
customer_id: 'cust_123',
feature_id: 'q3_brief',
},
});
const eventId = completion.id;
// Report the outcome once your app accepts or rejects the output.
await fetch(`https://p402.io/api/v2/meter/events/${eventId}/outcome`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.P402_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ outcome: 'accepted' }),
});
P402 meters economics, not content.
Metadata-only mode is the default. Prompts, files, documents, source code, and responses stay inside your environment. P402 records the owner, cost, tokens, budget, policy result, outcome, and evidence status of the call. Choose a different mode only when the tenant policy allows it.
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.
Start in Sandbox. Move to Build when you ship.
Sandbox is free. Build is $49 per month. Build checkout is controlled by the billing rollout. Start free or request access.
Add settlement only when AI work is payable.
Meter works without settlement. USDC and wallets are only required for x402 receipts when AI work is sold to an end user or billed across a boundary. Build and ship the meter first. Add receipts when the work becomes payable.
Does P402 require a wallet?+
No. Meter works without a wallet. Wallet and USDC are only for receipts on payable AI work.
Is the endpoint OpenAI-compatible?+
Yes. Point baseURL to https://p402.io/v1 and use the OpenAI SDK as-is.
What metadata can I attach?+
workflow_id, customer_id, feature_id, department, employee, model, vendor, and free-form tags within the documented vocabulary.
Does P402 store prompts?+
Not by default. Metadata-only mode keeps prompts and responses inside your environment.
Can I migrate from OpenRouter?+
Yes. P402 wraps OpenRouter and any provider. Same OpenAI SDK pattern.
What does the first metered event require?+
A P402 key and one wrapped call. Workflow and outcome metadata are optional but recommended for attribution.
Send the first event.
Start in Sandbox with one wrapped call. Add settlement when AI work becomes payable.