Loading...
Loading...
Set up Browser Use Cloud payments with x402 — pay per request from a crypto wallet (USDC on Base mainnet), no signup or API key. Two setups it works out up front — "just use it" (set up a wallet so you or Claude Code can run cloud browser tasks paid from the wallet — Claude writes and runs throwaway scripts, nothing touches your codebase) or "build it in" (install the SDK and write the key + code into your project). Walks through wallet setup, funding, .env, and a ~$1 test run. Use when the user asks about x402, pay-per-use, USDC payments, or wants Browser Use Cloud without an API key. For the free-tier signup (reverse-CAPTCHA → API key), use `browser-use cloud signup` or the `cloud` skill instead.
npx skill4agent add browser-use/browser-use x402browser-use-sdkbrowser-usebrowser-use<like this>questionquestionSETUPMODESETUPMODEUse x402questionx402 is a protocol from Coinbase that, instead of presenting an API key, allows you to use crypto to pay for API requests. x402 lets you pay Browser Use per request from a crypto wallet with USDC on Base — no signup, API key, or credit card needed, just a wallet. Setup takes a few minutes: get or make a wallet, add funds, save the key in, and test it..envHow do you want to use x402?
.envSETUP = ASETUP = BBROWSER_USE_API_KEYBROWSER_USE_API_KEY=./.env~/.browser-use/config.jsonbrowser-use cloud loginsignupbrowser-use doctorNo Browser Use key found, so I'll set this up accountless: the wallet is your identity, and the first payment makes a project named after it.
MODE = AAccountI found a Browser Use API key in <location>. Where should the USDC credits go?MODE = BMODE = AWalletDo you have a wallet ready, or should I set one up?.env.gitignoreAdd keyquestionYour wallet's private key needs to go into. You can paste it here and I'll add it for you, or add it yourself. Heads up: anything pasted in chat is saved in the transcript, so for a high-value wallet, adding it yourself is a bit safer. How do you want to do it?.env
.env.envBROWSER_USE_X402_PRIVATE_KEY=<pasted key>.env.envSaved your key to— I won't print it back..env
Add this line to your, then send me your wallet's public address (the.envone — safe to share):0x…BROWSER_USE_X402_PRIVATE_KEY=<your private key>
^0x[0-9a-fA-F]{40}$Got it:. That's a valid address.<address>
- Install MetaMask (or Rabby, Coinbase Wallet, Frame, Trust Wallet, Phantom, …) from the official site only: https://metamask.io. Make a wallet, save the seed phrase offline, set a password.
- Add Base as a network. Open https://chainlist.org/chain/8453 → "Connect Wallet" → "Add to MetaMask", then approve it in your wallet.
- Click "Buy" in your wallet. Pick USDC, network Base, pay with card / Apple Pay / bank. The USDC lands straight in your wallet.
- Get the private key: account menu → Account details → Show private key → enter password → copy.
- Add it to your
(make sure.envis gitignored):.envBROWSER_USE_X402_PRIVATE_KEY=<your private key>
- Send me your wallet's public address (the
one) so I can check it.0x…
.envpip install eth-accountfrom eth_account import Account
acc = Account.create()
print("Address:", acc.address)
print("Private key:", acc.key.hex())npm install viemimport { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
const key = generatePrivateKey();
console.log("Address:", privateKeyToAccount(key).address);
console.log("Private key:", key);Made a fresh wallet. Your public address is, and I've saved the private key to<address>. Now it needs funds..env
Your wallet's already funded, so we'll skip ahead to the test.
Two ways to get USDC into your wallet on Base:
- In-wallet Buy button (easiest): click "Buy", pick USDC, set the network to Base, pay with a card. No exchange needed.
- From an exchange: send USDC to
and pick "Base" as the network — not Ethereum, which costs $5–$20 in fees.<address>Add at least $20: that covers the $1 test plus a few real tasks. I'll watch the balance and tell you when it lands.
PADDED=$(printf "%064s" "${WALLET_ADDR:2}" | tr ' ' '0')
curl -s https://mainnet.base.org \
-H "Content-Type: application/json" \
-d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\",\"params\":[{\"to\":\"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\"data\":\"0x70a08231${PADDED}\"},\"latest\"],\"id\":1}"result1_000_000Funded — I see $<amount> on Base. Next, a quick test.
SETUP = ASETUP = Bpackage.jsontsconfig.jsonpyproject.tomlrequirements.txt*.py# Python (needs 3.10+ for the x402 extra)
pip install "browser-use-sdk[x402]"
# TypeScript
npm install browser-use-sdk @x402/fetch @x402/evm viemTest runReady to test? This spends exactly $1 USDC from your wallet to check payment + run work end to end.What's the task? Keep it short.max_valueimport asyncio, os
from decimal import Decimal
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
from eth_account import Account
async def main():
client = x402Client()
register_exact_evm_client(
client,
EthAccountSigner(Account.from_key(os.environ["BROWSER_USE_X402_PRIVATE_KEY"])),
)
# max_value caps the spend per request — picks the $1 option over the $5 default.
async with x402HttpxClient(client, max_value=Decimal("1.5"), timeout=180.0) as http:
resp = await http.post(
"https://x402.api.browser-use.com/api/v3/sessions",
json={"task": "<the task>"},
)
print(resp.status_code, resp.json())
asyncio.run(main())MODE = Basync with x402HttpxClient(
client, max_value=Decimal("1.5"), timeout=180.0,
headers={"X-Browser-Use-API-Key": os.environ["BROWSER_USE_API_KEY"]},
) as http:
...x402max_valueThat x402 version can't force a $1 charge, so the test will cost $5 instead. Want me to go ahead?Paid. On-chain proof: https://basescan.org/address/<address>#tokentxns — look for a USDC transfer out of exactly $1.000000.
MODE = Abrowser-use-sdkpip install -U "browser-use-sdk[x402]"import asyncio, os
from browser_use_sdk.v3 import get_wallet_balance
async def main():
bal = await get_wallet_balance(os.environ["BROWSER_USE_X402_PRIVATE_KEY"])
print(bal['total_credits_usd'])
asyncio.run(main())MODE = Bget_wallet_balancefrom browser_use_sdk.v3 import AsyncBrowserUse
client = AsyncBrowserUse(api_key=os.environ["BROWSER_USE_API_KEY"])
acct = await client.billing.account()
print(acct.total_credits_balance_usd)Done. Your Browser Use balance is now $<balance> (the test cost about $<cost>). Tasks draw from this, and the SDK adds another $5 when it runs out.
SETUP = AAll set. Ask me to run any browser task and I'll run it through the SDK, paid from your wallet.
/tmpBROWSER_USE_X402_PRIVATE_KEYimport asyncio, os
from browser_use_sdk.v3 import AsyncBrowserUse
async def main():
client = AsyncBrowserUse() # Mode B: AsyncBrowserUse(api_key=os.environ["BROWSER_USE_API_KEY"])
result = await client.run(task="<the task>")
print(result.output)
asyncio.run(main())SETUP = BAll set. Here's the client to use in your code — it reads the key and endpoint from your:.env
cloudfrom browser_use_sdk.v3 import AsyncBrowserUse
client = AsyncBrowserUse() # Mode A (accountless)
# client = AsyncBrowserUse(api_key="bu_...") # Mode B (top up existing account)BrowserUse| Python | TypeScript |
|---|---|
| |
| |
| |
| |
| |
BROWSER_USE_X402_PRIVATE_KEY.env.env.env.gitignore0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913