p402-agent-setup — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited p402-agent-setup (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Help developers integrate P402 as the AI routing and payment infrastructure for autonomous agents. The goal is the cleanest possible path from "I have an agent running somewhere" to "my agent routes all inference through P402 with budget caps, semantic caching, and on-chain settlement on Base or Tempo."
P402 is an OpenAI-compatible API. Any agent framework or tool that can call an OpenAI-style endpoint can use P402 as a drop-in provider. This is the key architectural insight: P402 is not a plugin or SDK dependency. It is a base URL swap.
P402 settles on multiple rails:
Auto-routing picks the cheaper rail by default (Tempo, when both are healthy). Users can override per request.
The three integration depths, from simplest to richest:
baseURL to https://p402.io/api/v2 and set the API key. The agent gets 300+ model routing, semantic caching, and Billing Guard protection with zero code changes.@p402/mcp-server globally or locally. The agent gains 6 tools for active session management, provider comparison, and health monitoring. The agent can self-manage its own budget.@p402/sdk for high-level operations, or @p402/mpp-method for direct mppx-protocol integration when building custom server infrastructure.Most agent users want option 1 or 2. Reach for option 3 only when building a custom agent framework, integrating mppx directly, or needing programmatic control over sessions and mandates.
When a user describes their setup, identify two things:
Then route to the appropriate reference file:
references/openclaw.mdreferences/generic-agent.mdreferences/environments.mdIf the user mentions both an agent framework and a hosting environment, read both relevant files and synthesize a complete answer.
When responding to agent setup questions:
.env with .gitignore, or the platform's secrets manager.cost mode (autonomous agents burn tokens fast). balanced is the default. quality is for high-stakes tasks. speed is for real-time conversational agents.POST https://p402.io/api/v2/chat/completionsPOST https://p402.io/api/v2/sessionsPOST https://p402.io/api/v2/sessions/fundGET https://p402.io/api/v2/sessions/{id}/statsPOST https://p402.io/api/v2/providers/compareGET https://p402.io/api/v2/modelsGET https://p402.io/api/v2/healthhttps://www.p402.io/status (no auth required, for uptime checks)https://p402.io/dashboard (session management, funding, analytics)Two paths are supported:
Authorization: Bearer <P402_API_KEY> (recommended for agent integrations; created at p402.io)Authorization: Payment <base64url JSON credential> (for clients integrating the Machine Payments Protocol directly)x402 backwards compatibility: existing X-PAYMENT and X-PAYMENT-REQUIRED headers are accepted through May 2027.
Standard OpenAI-compatible body with an optional p402 extension block:
{
"messages": [{"role": "user", "content": "..."}],
"model": "auto",
"p402": {
"mode": "cost",
"cache": true,
"session_id": "sess_xxx",
"preferred_rail": "auto",
"analytics_tag": "research-agent-v1"
}
}When model is "auto" or omitted, P402 selects the optimal model for the routing mode. To target a specific model, use the OpenRouter-style identifier (e.g., anthropic/claude-opus-4.7, openai/gpt-4o, groq/llama-3.3-70b) as returned by /api/v2/models.
cost: Cheapest capable model (DeepSeek V3, Haiku 4.5, GPT-4o-mini)quality: SOTA model (Claude Opus 4.7, GPT-5, Gemini 3 Pro)speed: Lowest TTFB (Groq LPU, Flash models)balanced: Weighted score 0.4 cost + 0.3 speed + 0.3 quality (default)Simple Mode: a zero-cost heuristic gate runs before full routing on every request. For straightforward queries (5-question complexity score ≥ 4/5), it routes direct to a cheap model and skips the full intelligence pipeline. Hidden by default; the agent does not need to configure it.
preferred_rail accepts "tempo", "base", or "auto" (default).
Auto-selection logic:
Most agents leave this as "auto". Override only when there is a specific reason (cross-chain interop, jurisdictional preferences, etc.).
Every response includes a p402_metadata object:
{
"provider": "anthropic",
"model": "anthropic/claude-sonnet-4.6",
"cost_usd": 0.0023,
"direct_cost": 0.0031,
"savings": 0.0008,
"input_tokens": 1200,
"output_tokens": 450,
"cached": false,
"latency_ms": 1840,
"payment_rail": "tempo",
"charge_amount_raw": "1000",
"analytics_tag": "research-agent-v1"
}payment_rail indicates which chain settled the charge. charge_amount_raw is the bigint amount in the smallest token unit, as a string. analytics_tag echoes the tag from the request, useful for cost attribution per agent, feature, or customer.
@p402/mcp-server on npmp402-mcpp402_chat, p402_create_session, p402_get_session, p402_list_models, p402_compare_providers, p402_healthPOST /api/v2/sessions with { "budget_usd": 5 }. Returns a session_id.POST /api/v2/sessions/fund with { session_id, amount, tx_hash }.session_id in the p402 options block on every chat request.GET /api/v2/sessions/{id}/stats for usage analytics, or check the dashboard.active | exhausted | expired | ended | revoked.For now, funding is handled by the user (send stablecoin from a wallet). Embedded fiat-to-stablecoin onramp is on the roadmap.
Six layers protect every request:
A 429 response with structured JSON indicates a Billing Guard rejection. The error body identifies which layer fired.
@p402/mpp-method PackageFor developers building their own server infrastructure (not just calling P402's HTTP API), the @p402/mpp-method package on npm provides direct mppx-protocol integration with two methods:
p402Charge: Multi-rail charge with auto-selection between Base and TempobaseCharge: Direct EIP-3009 settlement on Base mainnet or SepoliaUse this when building a custom agent framework that needs to issue or verify payment credentials directly. For most agent users, the HTTP API is the right surface.
The following are on the roadmap and not yet available. Do not promise these to users as currently functional:
@p402/mpp-method. Target: Q4 2026.OpenClaw, Zo Computer, Replit, Railway, Render, Fly.io, agent setup, provider configuration, MCP server, API key management, budget caps, session management, autonomous agent, always-on agent, OpenAI compatible, base URL, agent hosting, VM setup, cloud agent, personal AI agent, CrewAI, AutoGPT, LangChain, agent framework integration, p402 provider, routing mode, USDC settlement, USDC.e Tempo, multi-rail payment, Base settlement, Tempo settlement, mppx, x402, @p402/mpp-method, @p402/mcp-server, @p402/sdk, MCP, machine payments protocol, AI agent budget, AI agent costs, OpenRouter alternative, model routing, semantic cache.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.