<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dmitry Panevin | AI Automation</title>
    <description>The latest articles on DEV Community by Dmitry Panevin | AI Automation (@panevin_online).</description>
    <link>https://dev.to/panevin_online</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3830956%2Ff07e8f35-3a6d-43e9-9f01-5c7b83aa8f75.jpg</url>
      <title>DEV Community: Dmitry Panevin | AI Automation</title>
      <link>https://dev.to/panevin_online</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/panevin_online"/>
    <language>en</language>
    <item>
      <title>I Built 8 Paid API Endpoints for AI Agents Using x402 — Here's How</title>
      <dc:creator>Dmitry Panevin | AI Automation</dc:creator>
      <pubDate>Wed, 18 Mar 2026 09:33:21 +0000</pubDate>
      <link>https://dev.to/panevin_online/i-built-8-paid-api-endpoints-for-ai-agents-using-x402-heres-how-5f4o</link>
      <guid>https://dev.to/panevin_online/i-built-8-paid-api-endpoints-for-ai-agents-using-x402-heres-how-5f4o</guid>
      <description>&lt;h1&gt;
  
  
  I Built 8 Paid API Endpoints for AI Agents Using x402 — Here's How
&lt;/h1&gt;

&lt;p&gt;We talk a lot about AI agents being autonomous, but they often hit a wall when it comes to money. Most APIs require a human to sign up, add a credit card, and manage a monthly subscription. This is the "Last Mile" problem of agentic workflows. I wanted to build a service that agents could pay for themselves, one request at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Concept: Wallet-to-Wallet Economy
&lt;/h2&gt;

&lt;p&gt;The goal was simple: creating an API where the authentication IS the payment. No API keys, no signups. Just a pure protocol-level interaction where an agent requests data, receives a 402 Payment Required status, signs a transaction, and gets the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tech Stack: From Local Mac to Global API
&lt;/h2&gt;

&lt;p&gt;I built this on a modest setup that packs a punch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Home Base:&lt;/strong&gt; A Mac Mini at home.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway:&lt;/strong&gt; A VPS acting as a reverse proxy via SSH tunnel (Traefik + Nginx).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocol:&lt;/strong&gt; &lt;a href="https://x402.org" rel="noopener noreferrer"&gt;x402&lt;/a&gt; for micropayments on Base L2.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend:&lt;/strong&gt; Node.js + Express using the &lt;code&gt;@x402/express&lt;/code&gt; middleware.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Traffic Path:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;Client&lt;/code&gt; → &lt;code&gt;api.panevin.net&lt;/code&gt; (Cloud) → &lt;code&gt;Traefik (SSL)&lt;/code&gt; → &lt;code&gt;nginx-proxy&lt;/code&gt; → &lt;code&gt;SSH Tunnel&lt;/code&gt; → &lt;code&gt;Localhost:4020&lt;/code&gt; (Mac Mini).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why x402?
&lt;/h2&gt;

&lt;p&gt;I chose x402 because it allows for header-based payments. When an agent calls an endpoint without a payment header, the server returns a 402 error with payment details. The agent then signs a &lt;code&gt;transferWithAuthorization&lt;/code&gt; message, includes it in the header of the next request, and the transaction is settled on-chain. It is the ultimate friction-remover for machine-to-machine commerce.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 8 Endpoints &amp;amp; Pricing Strategy
&lt;/h2&gt;

&lt;p&gt;I focused on the most common tasks AI agents perform: web scraping and content processing. By using a smart LLM fallback chain on OpenRouter (starting with free-tier models like Qwen and Llama 3.3), I can keep prices extremely low.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Price (USDC)&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/extract/text&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.001&lt;/td&gt;
&lt;td&gt;Strip HTML tags, return clean text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/extract/links&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.001&lt;/td&gt;
&lt;td&gt;Extract all unique absolute hyperlinks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/extract/metadata&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.001&lt;/td&gt;
&lt;td&gt;Fetch Title, Description, and OG tags&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/transform/markdown&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.002&lt;/td&gt;
&lt;td&gt;Convert any HTML page to clean Markdown&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/extract/summary&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.003&lt;/td&gt;
&lt;td&gt;Basic high-speed text summary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/ai/summarize&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.005&lt;/td&gt;
&lt;td&gt;LLM-powered abstractive summary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/ai/translate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.005&lt;/td&gt;
&lt;td&gt;Professional LLM-based translation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/ai/extract-structured&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.008&lt;/td&gt;
&lt;td&gt;Schema-based JSON data extraction&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Lessons Learned: The Self-Hosted Facilitator
&lt;/h2&gt;

&lt;p&gt;Initially, I relied on external facilitators to verify payments. However, I found them intermittently unreliable. To achieve 100% uptime and autonomy, I built my own &lt;strong&gt;Local EVM Facilitator&lt;/strong&gt; using the &lt;code&gt;viem&lt;/code&gt; library. It handles the verification and settlement directly on the Base network using my own private key (stored securely in .env).&lt;/p&gt;

&lt;h2&gt;
  
  
  Discovery: Making the API Visible to Bots
&lt;/h2&gt;

&lt;p&gt;How do agents find this API? I implemented three layers of discovery:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/.well-known/x402&lt;/code&gt;&lt;/strong&gt;: Standard x402 manifest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;llms.txt&lt;/code&gt;&lt;/strong&gt;: For LLM-based agents to understand the service capabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;openapi.json&lt;/code&gt;&lt;/strong&gt;: For automatic tool registration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My API is now live and auto-registered on &lt;code&gt;x402scan&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This isn’t just about scraping; it’s a proof of concept for a world where agents earn USDC (via bounties or services) and spend it on specialized tools without human intervention. The machine-to-machine economy is already here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it out:&lt;/strong&gt; &lt;a href="https://api.panevin.net" rel="noopener noreferrer"&gt;https://api.panevin.net&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Learn the protocol:&lt;/strong&gt; &lt;a href="https://x402.org" rel="noopener noreferrer"&gt;x402.org&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built by PanevinBot.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>blockchain</category>
      <category>agents</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
