p402

p402 is a skill for Claude Code, Codex from Z333Q/p402-protocol. It costs 171 tokens per session (2,707 once invoked), scanned A, original, MIT.

An infrastructure layer for AI applications that chooses among language-model providers and handles per-request stablecoin payments on Base, a blockchain network.

In plain words
What is it for?
Use it to route requests by cost, speed, or quality, set spending limits, and pay providers per request.
Why use it?
It helps avoid tying an application to one provider and paying more than necessary, while making very small AI payments practical.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/z333q/p402-protocol/p402
Any agent
npx skills add Z333Q/p402-protocol --skill p402
Clone the repo
git clone --depth 1 https://github.com/Z333Q/p402-protocol

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for p402

README.md
[![agentmods](https://agentmods.dev/badge/skills/z333q/p402-protocol/p402.svg)](https://agentmods.dev/skills/z333q/p402-protocol/p402)
Your own site
<a href="https://agentmods.dev/skills/z333q/p402-protocol/p402"><img src="https://agentmods.dev/badge/skills/z333q/p402-protocol/p402.svg" alt="Measured on agentmods" height="20"></a>
Per session 171 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,707 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00171 $0.02707
Opus 5 $0.00086 $0.01354
Sonnet 5 $0.00034 $0.00541
Haiku 4.5 $0.00017 $0.00271

Measured 5d ago against content hash 91759ede660a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

p402 scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

For complete request/response schemas and code examples in TypeScript, Python, and curl, read `references/api-reference.md`.
skills/p402/SKILL.md · 173 lines

How it starts

The opening of the file, as written. The whole thing — 173 lines — stays where its author put it; the contents beside it link to each section on GitHub.

P402: Payment-Aware AI Orchestration

P402.io is an infrastructure layer that solves two problems at once: fragmented AI provider APIs and broken micropayment economics. It routes LLM requests to the optimal provider based on cost, speed, or quality, while settling payments in USDC/USDT on Base blockchain using the x402 protocol.

The key mental model: P402 sits between your application and AI providers the same way a payment network sits between merchants and banks. It handles routing, authorization, and settlement so your code just makes API calls.

Why P402 Exists

Traditional payment processors charge ~$0.30 per transaction, which makes micropayments for AI API calls (often $0.001-$0.05) economically impossible. P402 uses stablecoin settlement on Base L2 where transaction costs are fractions of a cent, enabling true pay-per-request economics for AI agents.

Most AI applications are "cost-blind" -- they hardcode a single provider and overpay by 70-85%. P402 makes applications "cost-aware" by exposing real-time pricing across 300+ models and routing intelligently.

Core Concepts

The Session Lifecycle

Sessions are the foundational primitive. Every interaction with P402 flows through a session:

  1. Create a session with a budget cap and optional policies
  2. Fund the session (USDC via Base Pay, direct transfer, or test credits)
  3. Use the session for chat completions -- P402 tracks spending per request
  4. Expire -- sessions auto-close when budget is exhausted or time limit is reached

Sessions enforce spending boundaries. An agent with a $10 session physically cannot spend $10.01. This is the core safety mechanism for autonomous agent spending.

Routing Modes

Every chat completion request can specify a routing mode that controls how P402 selects the provider and model:

Mode Optimizes For Best For Typical Provider
cost Lowest price, acceptable quality Batch processing, background tasks, high-volume DeepSeek V3.2, Haiku 4.5, GPT-4o-mini
quality Best output, price secondary Final outputs, complex reasoning, user-facing answers Claude Opus 4.6, GPT-5.2, Gemini 3.1 Pro
speed Lowest latency, price secondary Real-time chat, interactive UX, streaming Groq (LPU), Flash models
balanced Equal weight across all factors General purpose, default choice Sonnet 4.6, GPT-4o-mini, Gemini 3.1 Pro

Read the full file on GitHub · 173 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 173 lines · 171 tokens per session scan A 91759ede660a

Subscribe to this mod's changes

p402 is a skill published in the GitHub repository Z333Q/p402-protocol (0 stars, last pushed 1mo ago), licensed MIT. It adds 171 tokens to every session and 2,707 once invoked, about $0.0009 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

t2000-job

Escrow USDC for agent-to-agent deliverable work (A2A jobs). Use when hiring another agent for async work (research reports, builds, SLA tasks) or when selling deliverable work yourself (list a service: fixed price + SLA, no server needed), or posting/claiming open jobs on the board (t2 job open / claim) — anything…

mission69b/t2000 · 164 tokens

okx-agent-payments-protocol

Use when an agent hits HTTP 402 / payment-required, or the user mentions x402, x402Version, X-PAYMENT, PAYMENT-REQUIRED, PAYMENT-SIGNATURE, WWW-Authenticate: Payment, permit2, upto, metered billing, a payment channel / voucher / session, channelId / channelid, opening / closing / topping up / settling / refunding a…

internet-court/internet-court-skill · 231 tokens

jupiter-lend

Interact with Jupiter Lend Protocol. Read-only SDK (@jup-ag/lend-read) for querying liquidity pools, lending markets (jlTokens), and vaults. Write SDK (@jup-ag/lend) for lending (deposit/withdraw) and vault operations (deposit collateral, borrow, repay, manage positions).

internet-court/internet-court-skill · 68 tokens

okx-dapp-discovery

Plugin router for 20 third-party DeFi protocols (Polymarket, Aave, Hyperliquid, PancakeSwap, Morpho, Raydium, Curve, Compound, Pendle, Lido, ether.fi, GMX, Kamino, Orca, Meteora, Clanker, pump.fun, Uniswap) and their protocol-native tokens (HYPE, HLP, eETH, weETH, stETH, wstETH, LDO, GHO, CAKE, CRV, COMP, RAY, ETHFI…

internet-court/internet-court-skill · 351 tokens

lifi

LI.FI REST API for cross-chain and same-chain token swaps, bridging, DeFi deposits (Composer), yield discovery (Earn), and intent-based execution (Intents). USE THIS SKILL WHEN USER WANTS TO: Swap tokens between different blockchains (e.g., "swap USDC on Ethereum to ETH on Arbitrum") Bridge tokens to another chain…

internet-court/internet-court-skill · 299 tokens

t2000-receive

Generate a payment request for the t2000 Agent Wallet — print the wallet address, an ANSI QR code, and (via MCP) a Payment Kit URI (sui:pay?…). Use when asked to receive a payment, share a wallet address, create a payment link, or set up a fund-me link.

mission69b/t2000 · 71 tokens