npm.io
0.6.2 • Published 2d agoCLI

openspender

Licence
MIT
Version
0.6.2
Deps
0
Size
36 kB
Vulns
0
Weekly
0
Stars
3

openspender

CLI and JavaScript client for OpenSpender — the self-custodial wallet that lets AI agents like Claude Code pay for models, search, video, and compute as they go. Load once, then your agent buys what it needs, billed per call with no markup and no subscriptions.

OpenSpender routes requests to 15,000+ machine-payable endpoints across the x402 and MPP payment standards.

Connect every AI tool at once

npx openspender connect

Detects Claude Code, Codex, opencode, Gemini CLI, and Cursor, opens one browser approval, and wires every detected tool to OpenSpender's MCP server — each with its own freshly minted card at caps chosen on the consent screen. Tools are authenticated the moment the command finishes. Caps, activity, and revocation live at openspender.com/wallet.

Connect also installs the OpenSpender agent skill for each connected tool — fetched from openspender.com/SKILL.md at run time, so a rerun always installs the current version. Harnesses with a skills directory get the full file; harnesses that read a global memory file get a compact block between openspender:skill markers, and reruns replace only what sits between those markers — the rest of your files is never touched.

Flags: --dry-run previews without writing, --force rewrites existing entries, --no-auth skips the browser approval (each tool then authenticates itself on first use), --no-skill skips the skill install, and --card openspender_… uses one existing card for everything (headless machines, CI).

Getting started

npx openspender init

This sets up your local config, checks connectivity, and walks you through the two steps that happen in your browser and shell:

  1. Fund a wallet and mint an allowance token at openspender.com/wallet. OpenSpender is self-custodial — your keys, your money.

  2. Export the token so your tools can spend against the allowance:

    export OPENSPENDER_ALLOWANCE_TOKEN="<your token>"

Existing SDKs work unchanged by pointing them at the router. For Claude:

export ANTHROPIC_BASE_URL="https://openspender.com/v1/anthropic"
export ANTHROPIC_AUTH_TOKEN="$OPENSPENDER_ALLOWANCE_TOKEN"

Check your setup any time with:

npx openspender status

Library usage

Requires Node.js 18 or later.

import { OpenSpender } from "openspender";

const client = new OpenSpender(); // reads OPENSPENDER_ALLOWANCE_TOKEN

// Call any machine-payable endpoint: POST https://openspender.com/v1/{provider}/{endpoint}
const result = await client.request("exa", "search", {
  query: "latest x402 ecosystem news",
});

// Public network stats (no token required)
const stats = await client.stats();
console.log(stats.totalServices);

When a provider responds with 402 Payment Required, the OpenSpender router reads the challenge, checks it against your allowance, pays, and replays the request — your code just sees the result.

Status

Early release under active development — the API surface may change before 1.0. Feedback and issues are welcome at github.com/openspender/openspender.

Documentation

Full docs live at openspender.com/docs.

Security

OpenSpender handles payments, so we take security seriously. Please report vulnerabilities privately — see SECURITY.md.

License

MIT

Keywords