- Sign up at p402.io
- Go to Dashboard → Settings → API Keys
- Click Generate Key — copy it immediately (shown once)
- Set it as an environment variable:
export P402_API_KEY=p402_live_...curl -X POST https://p402.io/api/v2/chat/completions \
-H "Authorization: Bearer $P402_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "Hello from P402!" }],
"p402": { "mode": "cost" }
}'You'll get back an OpenAI-compatible response plus p402_metadata:
{
"choices": [{ "message": { "role": "assistant", "content": "Hello! ..." } }],
"p402_metadata": {
"provider": "deepseek",
"model": "deepseek-chat",
"cost_usd": 0.000089,
"latency_ms": 312,
"cached": false
}
}npm install @p402/sdk viemimport P402Client from '@p402/sdk';
const p402 = new P402Client({ apiKey: process.env.P402_API_KEY });
const res = await p402.chat({
messages: [{ role: 'user', content: 'Hello!' }],
p402: { mode: 'balanced' }
});npx p402 login # Prompts for your API key
npx p402 chat "Hello!"
npx p402 health| What | Where |
|---|---|
| Dashboard | p402.io/dashboard |
| Models + pricing | npx p402 models list or /api/v2/models |
| Routing guide | docs/routing-guide.md |
| Session budgets | docs/sessions.md |
| x402 payments | docs/x402-payments.md |
| A2A protocol | docs/a2a-protocol.md |
| Full examples | examples/ |
https://p402.io
All API versions are stable. No beta prefixes.
All authenticated endpoints require:
Authorization: Bearer p402_live_...
Public endpoints (health, supported, models) do not require authentication.