Home / Guides / Use Agent402 from Claude Code, Cursor, VS Code, Windsurf, Cline, Roo Code, Codex CLI, Gemini CLI, Muse Code, Continue, ElizaOS, AgentCore and any OpenAI SDK

Use Agent402 from Claude Code, Cursor, VS Code, Windsurf, Cline, Roo Code, Codex CLI, Gemini CLI, Muse Code, Continue, ElizaOS, AgentCore and any OpenAI SDK

Agent402 opens two doors to an agent host:

  • Models: an OpenAI-compatible gateway. Run the local wallet proxy (npx agent402-openclaw proxy, below) and point any client that accepts a base URL at http://127.0.0.1:8412/v1: it pays each call from your wallet over x402. A client can also use https://agent402.tools/v1/metered directly with a credits key issued earlier as the API key. Each request is quoted from its own body (input plus your max_tokens), from $0.001 a call. GET https://agent402.tools/v1/models lists every id with its price and input cap; auto (routed per prompt, flat $0.01) lives at https://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 the agent402-mcp stdio server, which pays wallet-only tools by card when AGENT402_CREDITS_KEY is set.

New credits keys are not on sale; a key (a402_…) bought earlier keeps working in every block below. GET /api/credits/balance (Bearer) reports what is left. Every route also answers a stock x402 402 (USDC on Base, Solana, Polygon, Arbitrum, Monad, Celo, Avalanche, Sei, Optimism, Stellar, or Algorand - or USDG on Robinhood Chain) 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 @x402/fetch @x402/evm viem
export AGENT402_WALLET_KEY=0x...      # an EVM key holding USDC on Base
export AGENT402_MAX_PER_CALL_USD=2    # per-call ceiling checked before signing
npx agent402-openclaw proxy           # serves http://127.0.0.1:8412/v1

Use model auto or any id from GET /v1/models. Run npx agent402-openclaw 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 claude-sonnet-5

With a credits key issued earlier, 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 claude-sonnet-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 / 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 agent402 https://agent402.tools/mcp

Paid tools by card, through the stdio server:

claude mcp add agent402 -e AGENT402_CREDITS_KEY=a402_... -- npx -y agent402-mcp

Or in .mcp.json at the project root:

{
  "mcpServers": {
    "agent402": {
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "${AGENT402_CREDITS_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 by card:

{
  "mcpServers": {
    "agent402": {
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "a402_..." }
    }
  }
}

Continue

config.yaml. A model entry for chat, plus the connector for agent mode:

models:
  - name: Agent402 (metered)
    provider: openai
    apiBase: https://agent402.tools/v1/metered
    apiKey: a402_...
    model: openai/gpt-4o-mini
    roles:
      - chat
mcpServers:
  - name: Agent402
    type: streamable-http
    url: https://agent402.tools/mcp

Any id from /v1/models works as model; the metered route takes up to 200,000 characters of input per request.

ElizaOS

Tools: the elizaos-plugin-agent402 plugin adds AGENT402_FIND / AGENT402_CALL / AGENT402_ABOUT actions ("plugins": ["elizaos-plugin-agent402"], setting AGENT402_CREDITS_KEY). Models: the OpenAI plugin reads its base URL from the environment, so no code changes:

OPENAI_BASE_URL=https://agent402.tools/v1/metered
OPENAI_API_KEY=a402_...
OPENAI_LARGE_MODEL=anthropic/claude-sonnet-5
OPENAI_MEDIUM_MODEL=openai/gpt-4o-mini
# embeddings live at /v1/embeddings ($0.002 a call), off the metered path
OPENAI_EMBEDDING_URL=https://agent402.tools/v1
OPENAI_EMBEDDING_MODEL=text-embedding-3-small

Any OpenAI SDK

With the credits key exported as AGENT402_CREDITS_KEY:

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-4o-mini",
    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-4o-mini",
  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, at https://agent402.tools/v1/metered (route /v1/metered/messages). Pass the credits 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 proof in X-PAYMENT; every Agent402 route answers a stock x402 v2 challenge, so nothing on our side needs configuring.

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 by card, through the stdio server with a credits key held in a prompted input (VS Code stores it, the file never carries it):

{
  "inputs": [{ "type": "promptString", "id": "agent402-key", "description": "Agent402 credits key (a402_...)", "password": true }],
  "servers": {
    "agent402": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_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 by card, with the key read from the environment (${env:VAR} interpolation is Windsurf's own):

{
  "mcpServers": {
    "agent402": {
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "${env:AGENT402_CREDITS_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 by card:

{
  "mcpServers": {
    "agent402": {
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "a402_..." },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Cline's own "OpenAI Compatible" provider also accepts a base URL, so the models door works too: base URL https://agent402.tools/v1/metered, the credits key as the API key, and a model id from /v1/models.

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 by card:

{
  "mcpServers": {
    "agent402": {
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "a402_..." },
      "alwaysAllow": [],
      "disabled": false
    }
  }
}

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 by card through the stdio server:

[mcp_servers.agent402]
command = "npx"
args = ["-y", "agent402-mcp"]
env = { AGENT402_CREDITS_KEY = "a402_..." }

Codex as a model host: 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 by card through the stdio server:

{
  "mcpServers": {
    "agent402": {
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "a402_..." }
    }
  }
}

Muse Code

Meta's Muse Code CLI reads MCP servers from the mcp_servers block of ~/.config/muse/settings.json (the file must carry "schema_version": 1). The hosted connector over Streamable HTTP for the free tier, and the stdio server for paid tools by card:

{
  "schema_version": 1,
  "mcp_servers": {
    "agent402": {
      "transport": "streamable_http",
      "url": "https://agent402.tools/mcp",
      "enabled": true,
      "mode": "optional"
    },
    "agent402-paid": {
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "agent402-mcp"],
      "env": { "AGENT402_CREDITS_KEY": "${AGENT402_CREDITS_KEY}" },
      "enabled": true,
      "mode": "optional"
    }
  }
}

mode: "optional" lets a session start even if a server is unreachable. Muse Code has no custom model provider setting, so it uses Agent402 for tools, not as its model host.

What the same key buys

The 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/why.

Packages for this guide

Back to guides