DEV Community

nanoempireai
nanoempireai

Posted on

How to Make Your API Agent-Discoverable with llms.txt

How to Make Your API Agent-Discoverable with llms.txt

AI agents don't browse Google. They crawl llms.txt at your domain root. Here's how to make your API findable.

The Discovery Problem

Autonomous agents are crawling the web right now looking for APIs to pay for. They don't read landing pages. They read machine-readable manifests:

  1. /llms.txt — Your API's resume for agents
  2. /agents.json — Schema.org structured data
  3. /openapi.json — With x-402-pricing extensions

Without these files, agents skip you entirely.

What Goes in llms.txt

# Your API Name

## Services
- Service Name: Description
  Price: $X.XX/call
  Endpoint: POST /api/endpoint
  Format: JSON in/out

## Authentication
- Protocol: x402 (HTTP 402)
- Currency: USDC on Base
- Gasless: true

## Payment
- Free tier: 5 calls/day per IP
- Paid: $0.05/call
Enter fullscreen mode Exit fullscreen mode

What Goes in agents.json

{
  "@context": "https://schema.org",
  "@type": "ItemList",
  "itemListElement": [{
    "@type": "Service",
    "name": "Your Service",
    "description": "What it does",
    "offers": {
      "@type": "Offer",
      "price": "0.05",
      "priceCurrency": "USD"
    },
    "availableChannel": {
      "@type": "ServiceChannel",
      "serviceUrl": "https://api.yoursite.com/endpoint"
    }
  }]
}
Enter fullscreen mode Exit fullscreen mode

The 3-Pillar Stack

File Purpose Required
llms.txt Human + machine readable manifest YES
agents.json Schema.org structured data YES
openapi.json With x-402-pricing extensions YES

The Payment Protocol

Agents pay via x402 (HTTP 402):

  1. Agent calls your endpoint
  2. Your API returns HTTP 402 with price + wallet
  3. Agent pays USDC on Base (gasless, EIP-3009)
  4. Agent retries with signed receipt
  5. You return 200 OK

Live Example

Our parser API generates these files automatically:

Result: 2 agents found us organically, paid $0.125 total.

One-Line Integration

pip install nano-empire-tollbooth
Enter fullscreen mode Exit fullscreen mode
from nano_empire_tollbooth import monetize

@monetize(price_usd=0.05)
@app.post("/api/your-endpoint")
async def your_endpoint(data: dict):
    return {"result": your_logic(data)}
Enter fullscreen mode Exit fullscreen mode

The SDK generates all three discovery files automatically.

Proof It Works

Our proof chain: $0.125 from 2 agents, 5 calls
View Live Proof Chain \u2192

Get Started

pip install nano-empire-tollbooth
Enter fullscreen mode Exit fullscreen mode

The SDK generates all three discovery files + x402 middleware + proof chain.


Live proof: https://api.nanoempireai.com/proof/summary
SDK: pip install nano-empire-tollbooth

Top comments (0)