Agent setup
Connect AI Agent
Inspect conditions and consumer_operations in tools/list or OpenAPI before sending an unsigned quote. The same structured decisions are available with REST and MCP. See the four decision examples.
For a remote MCP client, copy the endpoint and verify the connection. For code, choose REST, the typed Node SDK or a tested framework example. All three routes can inspect quotes without signing or spending.
MCP
Add a remote Streamable HTTP server. Set the URL below. Discovery uses no API key and connects without wallet access.
- Run
initialize, then send notifications/initialized. - Send
tools/list to see all 12 tools and their input schemas. - Use free
fresh402_register, try an eligible fresh402_check with evaluation:true, or inspect the challenge for a paid tool.
Use the protocol version returned by the server and forward an MCP session ID if one is issued. A paid MCP call can have HTTP 200 with result.isError and a challenge in the tool result.
Verify with the official Node MCP SDK
Node.js 24+. Save the JavaScript as discover.mjs and run node discover.mjs. Expect 12 tool names. Legacy clients supporting 2025-06-18 or 2025-11-25 can use initialization and the negotiated protocol header.
MCP inputs and payment metadata
REST
Send JSON to https://api.fresh402.com. Read current limits and tool schemas before execution.
Get an unpaid quote
Send the exact operation body with no payment credential or prepaid key. The Website Change examples below expect HTTP 402 before source work. Read its challenge to verify chain, native USDC, recipient, amount and resource before a separate authorization.
Generic MCP and HTTP clients can read quotes. Payment requires the compatible x402 or MPP client and explicit spending authority, or an eligible prepaid key.
Choose a payment method
Windows PowerShell
Read eligibility first. The second script makes a live Check only if eligible. Run it once when you intend to use the allowance.
Read walletless eligibility
Check only if eligible
Windows Command Prompt
Read release metadata, then inspect a quote. Use curl.exe to select the executable.
Read release metadata
Inspect an unpaid quote
Bash
Start with discovery, a fixed server fixture or an unpaid quote. Free Register may fetch and save a watch. Run it only when you need a baseline.
Read release metadata
Run the fixed server fixture
Register a free baseline
Initialize MCP
Inspect an unpaid quote
Python 3
Save as quote.py and run python quote.py. The script expects HTTP 402 and spends nothing.
Save quote.py
Node.js SDK
Use Node 24+ and ESM. Pin fresh402-sdk@0.7.0, the current published prerelease on next. The default latest tag selects 0.4.0-rc.1.
Install the pinned SDK
Save quote.mjs
Run quote.mjs
The package exports fresh402-sdk and fresh402-sdk/workflows. The client below prepares an unsigned quote without a key or signer. A caller supplies separate credentials and authorization for live paid execution.
Inspect the pinned npm package · Full SDK reference
Agent frameworks
Use a real client example for OpenAI Agents SDK, LangChain, LangGraph, CrewAI or Vercel AI SDK. Begin with discovery and an unpaid quote.
Choose a framework exampleChoose how the agent pays
- Without a wallet. List tools, run free Register or inspect a quote. Check free eligibility before a Check with
evaluation:true. - With a compatible wallet. Connect the x402 or MPP client. Check the exact resource, network, native USDC, merchant and amount. Set a spending limit before the host authorizes payment. Save the original operation for recovery.
- With a prepaid key. Read the authenticated service quote, verify its eligible balance and tariff, and set an exact maximum debit plus a stable idempotency key.
Compare payment methods · Recover an original operationSave what you need to continue or recover
For a fresh observation, supply an owned observation ID and the documented comparison mode. That request is a new operation. After a lost response, save the exact input, original payment credential or prepaid idempotency key, private recovery capability and original origin. Replay the original operation through its original access method. Never issue a replacement authorization while its status is uncertain.
Find the exact recovery path