Use Agent402 from Claude Code, Cursor, VS Code, Windsurf, Cline, Roo Code, Codex CLI, Gemini CLI, Continue, ElizaOS, Paperclip, HarnessRouter, AgentCore and any OpenAI SDK
Agent402 opens two doors to an agent host:
- Models: an OpenAI-compatible gateway. Run the local wallet proxy
(
agent402-model-provider proxy, below) and point any client that accepts a base URL athttp://127.0.0.1:8412/v1: it pays each call from your wallet over x402. With a credits key you already hold, a client can instead usehttps://agent402.tools/v1/metereddirectly with the key as its API key. Each request is quoted from its own body (input plus yourmax_tokens), from $0.001 a call. Set a client timeout of at least 120 s: the answer is generated and the payment settled before the response is sent, which takes a few seconds on most calls and longer for long answers, and a client that disconnects after the payment settles is charged without the answer (the charge is recorded as owed and reviewed for a refund).GET https://agent402.tools/v1/modelslists every id with its price and input cap;auto(routed per prompt, flat $0.01) lives athttps://agent402.tools/v1/auto. - Tools: the hosted MCP connector at
https://agent402.tools/mcp(discovery and the free tier need no key at all), or theagent402-mcpstdio server, which pays wallet-only tools from a wallet whenAGENT_KEYis set (an EVM key holding USDC;SOLANA_AGENT_KEYpays on Solana).
Already hold a credits key (a402_…) from before? It keeps working: put it
in AGENT402_CREDITS_KEY in place of AGENT_KEY in any stdio block below.
GET /api/credits/balance (Bearer) reports what a credits key has left. Use a
low-value wallet funded only with what you mean to spend. Every route also answers a stock x402 402
(USDC or USDG on fourteen chains) and an MPP challenge, so any x402 client pays per call with no key.
Pay from a wallet (local proxy)
The proxy runs on your machine, signs an x402 payment for each call from a wallet you hold (the key never leaves the machine), and forwards to the gateway. Any OpenAI-compatible client then uses it as its base URL:
npm i agent402-model-provider @x402/fetch @x402/evm viem # in one folder
export AGENT402_WALLET_KEY=0x... # an EVM key holding USDC on Base
export AGENT402_MAX_PER_CALL_USD=5 # per-call ceiling checked before signing (the default; 0 or off turns it off)
npx agent402-model-provider proxy # run from that folder; serves http://127.0.0.1:8412/v1
Install the four packages together and run the proxy from the same folder: the wallet packages are optional peers, so a proxy started without them runs unpaid and logs that x402 payment is unavailable.
Use model auto or any id from GET /v1/models. Run
npx agent402-model-provider permit2-approve once to settle metered calls at actual
usage instead of the quote. The proxy also answers the Anthropic wire
(POST /v1/messages), so Claude Code pays from the same wallet (next section).
Claude Code
Claude Code as an LLM client, billed per request under a quoted ceiling. With the local proxy running (above), point Claude Code at it and it pays each turn from your wallet:
export ANTHROPIC_BASE_URL=http://127.0.0.1:8412
export ANTHROPIC_AUTH_TOKEN=unused # the proxy pays; this value is ignored
claude --model anthropic/claude-sonnet-5.5
With a credits key you already hold, you can instead point
it at the metered tier with the credits key as the auth token (Bearer), keep
your usual model names - dated ids like claude-haiku-4-5-20251001 resolve
to the live model:
export ANTHROPIC_BASE_URL=https://agent402.tools/v1/metered
export ANTHROPIC_AUTH_TOKEN=a402_...
claude --model anthropic/claude-sonnet-5.5
Verified 2026-08-27 with claude-cli 2.1.250: a full turn (110 KB system
prompt + 22 tool schemas, adaptive thinking, streaming) and a tool-use round
trip both complete; each turn is quoted from its own body (/v1/metered
accepts bodies to 1 MB, with at least 200k input chars) and settles at actual usage, so an
idle turn costs cents, never the ceiling. Not carried on this wire:
output_config, context_management (dropped, the model default applies)
and server-side tools (web search, computer use) - Claude Code's own tools are
client tools and work as usual.
Tools over the hosted connector (free tier and discovery, no key):
claude mcp add --transport http -s user agent402 https://agent402.tools/mcp
Paid tools from a wallet, through the stdio server:
claude mcp add agent402 -e AGENT_KEY=0x... -- npx -y agent402-mcp@0.17.1
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
No wallet yet? Fund a first one with USDC on Base, no ETH needed, or run npx -y agent402-mcp@0.17.1 wallet new to make one on this computer: it stores the key and prints the address and the config, never the key.
Or in .mcp.json at the project root:
{
"mcpServers": {
"agent402": {
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "${AGENT_KEY}" }
}
}
}
Cursor
.cursor/mcp.json in the project (or ~/.cursor/mcp.json for every
project). Remote, no key:
{ "mcpServers": { "agent402": { "url": "https://agent402.tools/mcp" } } }
Paid tools from a wallet:
{
"mcpServers": {
"agent402": {
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "0x..." }
}
}
}
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
Paperclip
Add the hosted connector to a Paperclip company as a custom MCP server:
- Open Connectors, then Connect your own MCP server.
- Paste
https://agent402.tools/mcp. Paperclip inspects the server; the connector needs no sign-in and no key, so it goes straight to the discovered actions. - Choose which agents can use the connection, then save.
With no wallet, catalog.search, catalog.find, payment.info and
server.describe answer for free, and catalog.call runs the pure-CPU
tools (hash, uuid, base64, markdown, JSON and more) free through
proof-of-work, rate-limited. Wallet-only tools, the flagship web and market
tools among them, answer with their payment offer instead of a result (an x402 PaymentRequired beside the MPP challenges): an MCP client that pays x402 or MPP settles it in the same call, and a call that carries no payment
is never charged. Paperclip's connectors take a URL; to pay from your own
wallet, add the stdio server from the Cursor block above, with AGENT_KEY
set, as an MCP server on the agent itself. Prices are on /pricing.
Each action has its own setting on the connection's Permissions tab:
Allowed runs it without review, Ask first waits for a person to
approve each call, and Off removes it from the agent. A new connection
starts every action at Allowed. catalog.call and each flagship action
(pdf.markdown, macro.series, weather.current, browser.render, audio.transcribe, memory.read, memory.write, decide.plan, decide.execute) run a tool; set all of them to Ask first to review
every run.
HarnessRouter
Add the hosted connector to a HarnessRouter workspace as a remote MCP server (HarnessRouter connects remote servers over Streamable HTTP by default):
- In the console, open Add-ons and add an MCP server.
- Name it
agent402and give it the addresshttps://agent402.tools/mcp. The connector needs no sign-in and no key, so leave the server's token field empty. - To change which tools one setup uses, open the setup in Studio and choose Settings.
Over the API, a harness lists the connector in mcp_servers when you
create it:
curl -s -X POST "$HARNESSROUTER_BASE_URL/v1/harnesses" \
-H "Authorization: Bearer $HARNESSROUTER_API_KEY" -H "Content-Type: application/json" \
-d '{"name":"Research agent","base":"claude-code",
"mcp_servers":[{"name":"agent402","url":"https://agent402.tools/mcp","transport":"http"}]}'
PUT /v1/harnesses/{id} replaces the whole configuration, so to add the
connector to a harness that already exists, read it first and send back its
current fields with the entry appended to mcp_servers.
With no wallet, catalog.search, catalog.find, payment.info and
server.describe answer for free, and catalog.call runs the pure-CPU
tools (hash, uuid, base64, markdown, JSON and more) free through
proof-of-work, rate-limited. Wallet-only tools, the flagship web and market
tools among them, answer with their payment offer instead of a result (an x402 PaymentRequired beside the MPP challenges): an MCP client that pays x402 or MPP settles it in the same call, and a call that carries no payment
is never charged. To pay from your own wallet, put the stdio server from the
Cursor block above, with AGENT_KEY set, in a plugin's mcp.json:
HarnessRouter runs a stdio server only from a plugin, inside the session,
where the agent can read its variables. Prices are on /pricing.
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
Continue
config.yaml. A model entry for chat, plus the connector for agent mode:
models:
- name: Agent402 (metered)
provider: openai
apiBase: http://127.0.0.1:8412/v1 # the local wallet proxy (above)
apiKey: unused # the proxy pays from your wallet
model: openai/gpt-6-luna
roles:
- chat
mcpServers:
- name: Agent402
type: streamable-http
url: https://agent402.tools/mcp
Any id from /v1/models works as model. With a credits key you already
hold, use apiBase: https://agent402.tools/v1/metered and the key as
apiKey instead. The metered route takes
200,000 characters of input per request on every model, and more on a
model with a larger context window, up to 1,000,000.
ElizaOS
Tools: the agent402-actions-plugin
plugin adds AGENT402_FIND / AGENT402_CALL / AGENT402_ABOUT actions
("plugins": ["agent402-actions-plugin"], setting AGENT402_WALLET_KEY to an
EVM key holding USDC, or AGENT402_CREDITS_KEY for a credits key you already hold).
Models: the OpenAI plugin reads its base URL from the environment, so no code
changes. With the local wallet proxy running (above):
OPENAI_BASE_URL=http://127.0.0.1:8412/v1
OPENAI_API_KEY=unused
OPENAI_LARGE_MODEL=anthropic/claude-sonnet-5.5
OPENAI_MEDIUM_MODEL=openai/gpt-6-luna
The proxy serves chat. Embeddings live at /v1/embeddings
($0.002 a call), which the proxy does not forward: with a credits
key you already hold, set OPENAI_EMBEDDING_URL=https://agent402.tools/v1 and
OPENAI_EMBEDDING_MODEL=text-embedding-3-small, with the key as the API key.
Any OpenAI SDK
With the local wallet proxy running (above), point the SDK at it; the proxy pays each call from your wallet:
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8412/v1", api_key="unused")
r = client.chat.completions.create(model="openai/gpt-6-luna",
messages=[{"role": "user", "content": "One sentence on x402."}], max_tokens=60)
print(r.choices[0].message.content)
With a credits key you already hold, exported as AGENT402_CREDITS_KEY, call
the metered route directly:
import os
from openai import OpenAI
client = OpenAI(base_url="https://agent402.tools/v1/metered", api_key=os.environ["AGENT402_CREDITS_KEY"])
r = client.chat.completions.create(model="openai/gpt-6-luna",
messages=[{"role": "user", "content": "One sentence on x402."}], max_tokens=60)
print(r.choices[0].message.content)
import OpenAI from "openai";
const apiKey = process.env.AGENT402_CREDITS_KEY;
// Stop here when it is unset: the SDK would otherwise fall back to OPENAI_API_KEY
// and send that key to this base URL.
if (!apiKey) throw new Error("export AGENT402_CREDITS_KEY first");
const client = new OpenAI({ baseURL: "https://agent402.tools/v1/metered", apiKey });
const r = await client.chat.completions.create({ model: "openai/gpt-6-luna",
messages: [{ role: "user", content: "One sentence on x402." }], max_tokens: 60 });
console.log(r.choices[0].message.content);
Send an Idempotency-Key header on retries and a retried call replays the
paid answer instead of paying again.
The same metered pricing is on the Responses wire too, for the OpenAI Agents
SDK and responses.create(): base URL https://agent402.tools/v1/metered
(route /v1/metered/responses), function tools only, store always false.
Any Anthropic SDK (Messages wire)
The same metered pricing on the Anthropic Messages wire. From a wallet, point
the SDK's base URL at the local proxy (http://127.0.0.1:8412, which answers
POST /v1/messages) with any placeholder key. With a credits key you already
hold, use https://agent402.tools/v1/metered (route /v1/metered/messages)
and pass the key as the SDK's auth_token (sent as Authorization: Bearer, which
the credits gate reads), not api_key (sent as x-api-key):
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://agent402.tools/v1/metered", auth_token=os.environ["AGENT402_CREDITS_KEY"])
m = client.messages.create(model="anthropic/claude-haiku-4.5", max_tokens=60,
messages=[{"role": "user", "content": "One sentence on x402."}])
print(m.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const authToken = process.env.AGENT402_CREDITS_KEY;
if (!authToken) throw new Error("export AGENT402_CREDITS_KEY first");
// apiKey: null keeps the SDK from reading ANTHROPIC_API_KEY from the
// environment and sending it here as x-api-key.
const client = new Anthropic({ baseURL: "https://agent402.tools/v1/metered", apiKey: null, authToken });
const m = await client.messages.create({ model: "anthropic/claude-haiku-4.5", max_tokens: 60,
messages: [{ role: "user", content: "One sentence on x402." }] });
console.log(m.content[0].text);
Amazon Bedrock AgentCore
An AgentCore Gateway turns https://agent402.tools/openapi.json into MCP
tools with an OpenAPI target (agentcore add gateway-target --type open-api-schema --schema <path to openapi.json>), or aggregates the hosted
connector as an MCP server target. Paid calls ride
AgentCore Payments:
the agent forwards our 402 payload, AgentCore signs it from its managed
wallet, and the retry carries the signed payment header; every Agent402 route
answers a stock x402 v2 challenge, so nothing on our side needs configuring.
The Payments plugin's client (User-Agent python-httpx) gets the x402 offer
alone and pays over x402 with no extra configuration; to pay over MPP on Tempo, send
X-Payment-Offers: mpp with the request, hold Tempo funds, and configure
the plugin with network_preferences_config=["tempo:4217", "eip155:4217"]
(Tempo first) and buyer_pays_gas_fees=True.
VS Code
GitHub Copilot's agent mode reads .vscode/mcp.json in the workspace (or
the user profile via the MCP: Open User Configuration command; MCP: Add Server in the palette writes either). Remote, free tier, no key:
{ "servers": { "agent402": { "type": "http", "url": "https://agent402.tools/mcp" } } }
Paid tools from a wallet, through the stdio server with the key held in a prompted input (VS Code stores it, the file never carries it):
{
"inputs": [{ "type": "promptString", "id": "agent402-key", "description": "EVM private key holding USDC (0x...)", "password": true }],
"servers": {
"agent402": {
"type": "stdio",
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "${input:agent402-key}" }
}
}
}
Windsurf
Cascade reads ~/.codeium/windsurf/mcp_config.json (Streamable HTTP, SSE
and stdio are all supported; note Cascade caps the tools it can see at 100 in
total across servers, and this connector lists a small fixed set, not the
whole catalog). Remote, free tier:
{ "mcpServers": { "agent402": { "serverUrl": "https://agent402.tools/mcp" } } }
Paid tools from a wallet, with the key read from the environment (${env:VAR}
interpolation is Windsurf's own):
{
"mcpServers": {
"agent402": {
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "${env:AGENT_KEY}" }
}
}
}
Cline
MCP Servers icon in the top toolbar, Configure tab, then Configure MCP
Servers (the CLI reads ~/.cline/mcp.json). Remote, free tier:
{
"mcpServers": {
"agent402": { "type": "streamableHttp", "url": "https://agent402.tools/mcp", "disabled": false, "autoApprove": [] }
}
}
Paid tools from a wallet:
{
"mcpServers": {
"agent402": {
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "0x..." },
"disabled": false,
"autoApprove": []
}
}
}
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
Cline's own "OpenAI Compatible" provider also accepts a base URL, so the
models door works too: base URL http://127.0.0.1:8412/v1 (the local wallet
proxy, above) with any placeholder API key, and a model id from
/v1/models. A credits key you already hold works with base URL
https://agent402.tools/v1/metered and the key as the API key.
Roo Code
Settings icon in the Roo pane, then Edit Global MCP (mcp_settings.json) or
Edit Project MCP (.roo/mcp.json, which wins on a name clash). Remote,
free tier:
{
"mcpServers": {
"agent402": { "type": "streamable-http", "url": "https://agent402.tools/mcp", "alwaysAllow": [], "disabled": false }
}
}
Paid tools from a wallet:
{
"mcpServers": {
"agent402": {
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "0x..." },
"alwaysAllow": [],
"disabled": false
}
}
}
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
OpenAI Codex CLI
One command for the free tier:
codex mcp add agent402 --url https://agent402.tools/mcp
Or in ~/.codex/config.toml, paid tools from a wallet through the stdio server:
[mcp_servers.agent402]
command = "npx"
args = ["-y", "agent402-mcp@0.17.1"]
env = { AGENT_KEY = "0x..." }
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
Codex as a model host, with a credits key you already hold (the local proxy
does not serve the Responses wire): its model_providers speak the Responses wire, and
the metered tier serves it at /v1/metered/responses (quoted per request
from the body, settled at actual usage for a credits key). In
~/.codex/config.toml:
model_provider = "agent402"
model = "anthropic/claude-haiku-4.5"
[model_providers.agent402]
name = "Agent402 (metered)"
base_url = "https://agent402.tools/v1/metered"
env_key = "AGENT402_CREDITS_KEY"
wire_api = "responses"
Then export AGENT402_CREDITS_KEY=a402_... and run codex. The route is
proven daily by the paid canary; a full Codex session against it has not yet
been run end to end, so if a turn is refused, the 400 body says exactly which
field (server tools and previous_response_id are not served).
Gemini CLI
One command for the free tier:
gemini mcp add --transport http agent402 https://agent402.tools/mcp
Or in ~/.gemini/settings.json (httpUrl is the Streamable HTTP key;
url means SSE), paid tools from a wallet through the stdio server:
{
"mcpServers": {
"agent402": {
"command": "npx",
"args": ["-y", "agent402-mcp@0.17.1"],
"env": { "AGENT_KEY": "0x..." }
}
}
}
Use a new wallet holding only a few dollars of USDC. Never your main wallet.
What the same wallet buys
The wallet (or credits key) that pays for chat pays for the rest: four wires on every tier (OpenAI chat, OpenAI Responses, Anthropic Messages, Gemini generateContent), embeddings, rerank, images, speech and transcription, 500+ tools, finished reports and monitors, and a router that buys from other sellers and resells the result, proven sellers first. Why pay here, with the proof links: agent402.tools/docs#why.
Packages for this guide
- OpenAI function calling (
agent402-function-calling) - Anthropic tool use (
agent402-messages-tools) - LangChain.js and LangGraph (
agent402-structured-tools) - OpenAI Agents SDK (
agent402-runner-tools) - Strands Agents (
agent402-agent-loop-tools) - elizaOS plugin (
agent402-actions-plugin) - MCP server (
agent402-mcp) - OpenClaw model provider (
agent402-model-provider)