New:Socket for Asana Is Now Available.Learn more
Get Started

@p402/cli

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@p402/cli

Official CLI for the P402 AI Payment Router

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

@p402/cli

npm License: MIT

Official CLI for the P402 AI Payment Router.

Installation

# Use without installing (recommended for quick start)
npx p402 --help

# Or install globally
npm install -g @p402/cli

Quick Start

# 1. Authenticate (saves key to ~/.p402/config.json)
npx p402 login

# 2. Chat via the cheapest provider
npx p402 chat "Explain EIP-3009 in one sentence" --mode cost

# 3. Check facilitator status
npx p402 health

Commands

p402 login

p402 login [--key <apiKey>] [--url <routerUrl>]

Stores your API key in ~/.p402/config.json. Get your key at p402.io/dashboard/settings.

p402 config

p402 config [--json]

Show current CLI configuration (API key masked).

p402 chat <message>

p402 chat <message> [--mode cost|quality|speed|balanced] [--model <id>]
                    [--session <id>] [--stream] [--json]

Send a chat message through the P402 router.

FlagDefaultDescription
--modebalancedRouting mode
--model(auto)Override model (e.g. gpt-4o, claude-3-5-sonnet)
--sessionAttach to an existing session ID
--streamfalseStream tokens as they arrive
--jsonfalsePrint full API response as JSON

p402 health

p402 health [--json]

Check P402 facilitator health (status, network, gas price, block number).

p402 models list

p402 models list [--json]

List all available models across providers.

p402 providers list

p402 providers list [--json]

List all AI providers with status and latency.

p402 providers compare

p402 providers compare [--prompt <text>] [--json]

Compare providers for a given prompt.

p402 session list

p402 session list [--json]

List active sessions and their budgets.

p402 session get <id>

p402 session get <id> [--json]

Get session details including budget breakdown.

p402 session create

p402 session create --budget <usd> [--agent <id>] [--wallet <address>]
                    [--expires <hours>] [--json]

Create a new budget-capped session.

FlagDefaultDescription
--budgetrequiredBudget in USD (e.g. 5.00)
--agentAgent ID to associate
--walletWallet address
--expires24Expire after N hours

p402 session fund <id> <amount>

p402 session fund <id> <amount> [--tx <hash>] [--json]

Add budget to an existing session. Provide --tx if topping up via on-chain transfer.

p402 mandate list

p402 mandate list [--status active|exhausted|expired|revoked] [--json]

List AP2 spending mandates.

p402 mandate create

p402 mandate create --user <did> --agent <did> --max <usd>
                    [--categories <list>] [--until <iso>] [--type <type>] [--json]

Create a new AP2 spending mandate.

FlagDefaultDescription
--userrequiredUser DID (e.g. did:pkh:eip155:8453:0x...)
--agentrequiredAgent DID
--maxrequiredMaximum spend in USD
--categoriesComma-separated allowed categories
--untilneverExpiry in ISO 8601 (e.g. 2026-12-31T00:00:00Z)
--typepaymentintent | cart | payment

p402 analytics spend

p402 analytics spend [--period 1d|7d|30d] [--json]

View spend analytics (total, per-request average, top providers).

p402 agent register <address>

p402 agent register <walletAddress> [--json]

Check if a wallet address is registered in the World AgentKit AgentBook contract on Base mainnet. Returns registration status, human_verified flag, and free-trial usage remaining.

p402 agent status

p402 agent status [--json]

Show World AgentKit status for the agent configured via P402_AGENT_ADDRESS. Returns registration, reputation score, and current credit balance.

p402 credits balance

p402 credits balance [--json]

Show current credit balance (1 credit = $0.01 USD). World ID-verified users receive 500 free credits on first verification.

p402 credits buy

p402 credits buy <amount_usd> [--mode test|paid] [--json]

Purchase additional credits.

FlagDefaultDescription
amount_usdrequiredAmount in USD (e.g. 5)
--modepaidtest for sandbox credits, paid for real USDC

Configuration

The CLI reads config from (in priority order):

  • Environment variables: P402_API_KEY, P402_ROUTER_URL
  • Config file: ~/.p402/config.json
{
  "apiKey": "p402_live_...",
  "routerUrl": "https://p402.io"
}

Keywords

p402

FAQs

Package last updated on 05 May 2026

Related posts