慣性聚合 高效追蹤和閱讀你感興趣的部落格、新聞、科技資訊
閱讀原文 在慣性聚合中打開

推薦訂閱源

博客园 - 司徒正美
V
V2EX
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
月光博客
月光博客
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
您的 AI Agent 現在可以使用 x402 支付每次抓取 0.001 美元 — 不需要 API 金鑰
HSH Intellig · 2026-05-24 · via DEV Community

當 AI 代理今日需要呼叫 API 時,他們會遇到障礙。註冊。獲取一個金鑰。管理輪換。觸發速率限制。支付一個與實際使用不匹配的訂閱。

那個模型是為了人類點擊儀表板而建立的。它不適用於代理。

我們剛剛發布了 AgentScrape — 一個按次付費的網頁掃描 API,供 AI 執行緒使用,並使用 x402 支付協議。每個呼叫費用為 0.001 美元 USDC 在 Base 主網上。無需註冊。無需 API 金鑰。執行緒按請求付費並獲取數據.

這篇文章是關於 x402 如何運作、我們建造了什麼,以及如何立即將 AgentScrape 插入您的執行緒.


AI 執行緒使用 API 金鑰的問題

API 金鑰是為靜態世界設計的:一位開發者、一個產品、一筆帳單。代理程式打破了所有三個假設.

單一 LangChain 代理程式可能在一個任務中呼叫三十個不同的 API。每個 API 都需要自己的金鑰、自己的驗證流程、自己的訂閱等級。開發者必須預測代理程式需要哪些 API,註冊每一個,並配置輪換邏輯。

結果是一堆無用的胶水程式碼,無法幫助代理程式做實際工作。更糟的是,代理程式無法呼叫開發者未事先安排的 API。

代理程式真正想要的,是一個可以讓他們發現服務、查看其價格、支付他們所需精確呼叫的費用,然後繼續前進的協議。沒有帳戶。沒有金鑰。沒有承諾。

這個協議已經存在。它叫做 x402


x402 在 60 秒內的運作方式

x402 是一個基於 HTTP 402 狀態碼(自 1997 年起保留的「需要付費」碼,且幾乎未被使用)構建的支付協議。

流程是:

  1. 代理呼叫 API。 無需驗證。
  2. API 回應 HTTP 402。 體內包含價格 ($0.001)、網絡 (Base mainnet)、接收者錢包地址,以及資產 (USDC).
  3. 代理簽署 USDC 轉賬授權 使用 EIP-3009 (無 gas、鏈下簽署).
  4. 代理重試呼叫X-PAYMENT 標頭中使用已簽署的付款有效負載.
  5. API 通過促進服務驗證付款,然後在鏈上處理它。
  6. API 返回數據。

促進者處理所有區塊鏈互動。API 伺服器不需要 RPC 节點、熱錢包或交易簽名。代理不需要在任何地方開戶,除了自托管錢包。

Coinbase 運營生產 x402 促進者。api.cdp.coinbase.com/platform/v2/x402。他們在 Base 主網上免收中間人費用 — 僅收網絡的虛擬燃料成本,他們為買家贊助這部分費用.


我們建設的:AgentScrape v0.6.0

AgentScrape透過 HTTP REST API 和 MCP (Model Context Protocol) 伺服器提供六項付費工具:

  • scrape_webpage — 清潔 HTML/Markdown/文本/JSON 提取
  • extract_structured_data — 借助 Groq + Llama 的模式定義 JSON 提取
  • screenshot_webpage — 全頁 PNG 截圖帶視口控制
  • extract_metadata — Open Graph、Twitter 卡片、JSON-LD 解析
  • create_browser_session — 持續瀏覽器上下文以用於多步流程
  • run_workflow — 在單一調用中組合多步操作

每個工具每次調用收費 $0.001。每個錢包的前 10 次調用免費用於評估.

The Stack

整個系統運行在 Cloudflare Workers 上:

  • 執行環境: Cloudflare Workers (V8 isolate, 全球邊緣部署)
  • 瀏覽器: Cloudflare 瀏覽器渲染 (受管理的無頭 Chrome)
  • HTTP 框架: Hono v4 與 @x402/hono v2 支付中間件
  • MCP 傳輸: agents/mcp +agents/x402來自 Cloudflare Agents SDK
  • 促進者:Coinbase CDP atapi.cdp.coinbase.com/platform/v2/x402
  • 權限:Ed25519 簽署的 JWTjose(與工作人員兼容,透過 Web Crypto API)
  • AI 提取:使用Llama 4 Scout (17B) 的 Groq 推理

The Worker 是 ~1000 行 TypeScript。總部署包:548 KB 壓縮後。冷啟動:72ms.


立即嘗試

作為 Claude Desktop、Cursor 或任何 MCP 客戶端的 MCP 伺服器

透過 Smithery 以單一指令安裝:

npx -y @smithery/cli install hshintelligence/agentscrape --client claude

進入全螢幕模式 退出全螢幕模式

這註冊了六個付費工具,您的代理可以直接呼叫。代理透過 Cloudflare 的 agents/x402 客戶端包裝器自動處理付款 — 您永遠看不到金鑰提示.

作為 Direct HTTP API

# 1. Request — get a 402 with payment requirements
curl -X POST https://agent-scrape.healingsunhaven.workers.dev/scrape \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","format":"markdown"}'

# Response:
# HTTP/2 402
# payment-required: <base64-encoded x402 v2 PaymentRequired>

進入全螢幕模式 退出全螢幕模式

Thepayment-required 標頭解碼為一個完整的 x402 v2 支付需求物件:方案、網絡、金額、USDC 資產地址、payTo 錢包,以及超時時間。

使用 @x402/fetch 或任何 x402 符合規範的封裝程式簽署支付並自動重試。第二次呼叫返回掃描的數據。

免費層

如果你只想測試抓取而不需要設定錢包,HTTP API 提供每個錢包每30天10次免費呼叫。設定一個 x402-payer 標頭,使用任何識別碼:

curl -X POST https://agent-scrape.healingsunhaven.workers.dev/scrape \
  -H "Content-Type: application/json" \
  -H "x402-payer: my-test-id" \
  -d '{"url":"https://news.ycombinator.com"}'

進入全螢幕模式 退出全螢幕模式


我們從這次發行學到的內容

一些從開發過程中學到的注意事項,可能會為其他團隊節省時間:

CDP促進者URL是api.cdp.coinbase.com/platform/v2/x402,而非x402.org/facilitator x402.org 的促進者僅限於測試網絡(Base Sepolia, Solana Devnet)。若要在 Base 主網進行實際交易,您需要 CDP 端點與 CDP API 金鑰。

認證採用 Ed25519 JWT,而非 API 金鑰標頭。 每次驗證/結算調用都需要一個新簽署的 JWT,其聲明包含iss: "cdp"sub: <keyId>aud: ["cdp_service"]uri: "<METHOD> api.cdp.coinbase.com<path>",以及 120 秒的過期時間。

CDP 提供給你一個原始的 88 字元的 base64 金鑰,不是 PKCS#8 PEM。 jose 套件需要 PKCS#8。轉換是直接的:取解碼金鑰的前 32 個字節,加上 Ed25519 PKCS#8 ASN.1 前綴 (302e020100300506032b657004220420),包裝在 PEM 標頭內。

agents/x402@x402/core 套件共享相同。FacilitatorConfig 介面. 您只需要寫一個 createAuthHeaders 回調函數,並將其傳遞給 HTTP 中介軟體 (HTTPFacilitatorClient) 和 MCP 層 (withX402).

Coinbase Bazaar (他們的官方 x402 發現目錄) 會自動索引. 無需 PR、無需表單、無需宣告檔案。添加 bazaarResourceServerExtension 即可declareDiscoveryExtension() 每條路線,透過 CDP 完成一次成功結算,你的服務將在 api.cdp.coinbase.com/platform/v2/x402/discovery/resources 內出現,時間不超過 10 分鐘.


AgentScrape 的下一步發展

目前,每個工具的價格為每 48 小時市場驗證 $0.001。一旦我們擁有結算數據,價格將轉為分層結構,反映每個操作的實際計算成本。

我們也在開發兩款相鄰的產品:AgentParse (PDF/OCR 提取) 和 AgentSearch (跨網絡、arXiv + GitHub 的聯合搜尋)。三款產品將共享相同的 x402 支付界面,所以採用其中一款的代理可以免費獲得其他兩款。

如果你正在開發代理並想跳過 API 金鑰粘合代碼,請嘗試 AgentScrape。給倉庫加星,通過 Smithery 安裝,或直接調用 HTTP 端點。歡迎提供反饋和錯誤報告。

連結: