DEV Community

Alex
Alex

Posted on

I made my API discoverable to AI agents — and got it paid per call — in 15 minutes

Everyone's writing about "the agent economy." Agents that hire agents, pay for tools, settle automatically. Lovely slides. What I actually wanted was smaller and more concrete: could I take a tiny HTTP endpoint I wrote, make it discoverable to autonomous agents, and have it get paid per call — without onboarding to a SaaS, signing a contract, or building a billing system?

Turns out yes, and the whole loop took about 15 minutes. Here's the exact path, including the dumb thing that cost me ten of those minutes.

The mental model (30 seconds)

There's an open marketplace — the AIMarket Hub — that sits between people who publish capabilities and agents that consume them. You give the hub a manifest (name, price, input/output schemas, and your public invoke_url). When an agent searches, finds your capability, and invokes it, the hub routes the call to your endpoint and settles payment. The demand-side reference client is an agent called ARGUS, but any MCP/HTTP client works.

You don't need the big monorepo or any of the AI-factory machinery — just a public HTTPS endpoint (or localhost + a tunnel for dev) and the hub CLI.

0 · Prereqs (2 min)

  • Python 3.11+ (or Node 20+) for the example server
  • The hub CLI: pip install -e aimarket-hub/ (from the MIT repo)
  • A hub to publish to: the public https://modelmarket.dev, or run your own with aimarket serve on :9083

1 · Run the example capability (3 min)

The repo ships a working one at aimarket-hub/examples/hello-capability:

cd aimarket-hub/examples/hello-capability
python3 server.py        # → http://127.0.0.1:3456/invoke
Enter fullscreen mode Exit fullscreen mode

The contract is deliberately boring — your endpoint accepts POST with JSON and returns a result:

curl -s -X POST http://127.0.0.1:3456/invoke \
  -H 'Content-Type: application/json' \
  -d '{"input":{"name":"dev"}}' | jq
# → {"success":true,"result":{"greeting":"Hello, dev!"}}
Enter fullscreen mode Exit fullscreen mode

Your server gets { "input": {...}, "product_id": "...", "capability_id": "..." } and returns HTTP 200 with {"result": {...}} (or {"output": {...}}). That's the whole interface. Any framework that can serve a POST route qualifies.

2 · Write the manifest (2 min)

capability.json:

{
  "product_id": "demo-hello",
  "capability_id": "greet@v1",
  "name": "greet",
  "description": "Says hello — 15-minute developer demo",
  "invoke_url": "https://YOUR-PUBLIC-HOST/invoke",
  "price_per_call_usd": 0.01,
  "publisher": "your-github-handle",
  "input_schema":  { "type": "object", "properties": { "name": { "type": "string" } } },
  "output_schema": { "type": "object", "properties": { "greeting": { "type": "string" } } }
}
Enter fullscreen mode Exit fullscreen mode

price_per_call_usd is exactly what a caller pays per successful invoke. capability_id follows tool.name@v1.

3 · Publish (2 min)

aimarket publish capability.json --hub https://modelmarket.dev
Enter fullscreen mode Exit fullscreen mode

Now it's in the catalog. An agent can search for it and invoke it, the hub meters the call, and you earn on settlement (USDC on Base on the buyer side; you receive via hub settlement).

Where it bit me (the honest part)

My first aimarket publish against a local hub kept failing, and I burned a solid ten minutes assuming my JSON was malformed. It wasn't. The hub rejects an invoke_url that isn't publicly reachablehttp://127.0.0.1:3456 is not a thing an agent on another machine can call, so it refuses to list it. That's correct behavior (a catalog full of localhost listings is useless), but the error didn't scream "your URL is local."

The fix for local dev is one env var on the hub process:

export AIMARKET_ALLOW_LOCAL_PUBLISH=1   # dev only — lets localhost invoke_urls through
Enter fullscreen mode Exit fullscreen mode

In real life you point invoke_url at a public HTTPS host (or a tunnel). Lesson: when a publish silently refuses, check the reachability of your URL before you re-read your schema for the fifth time.

The part I didn't have to build: trust

The reason I'd actually let a stranger's agent call my endpoint — and the reason I'd call someone else's — is that production hubs don't run on vibes. When you publish to a hardened hub, the path is guarded by:

  • a stake deposit before you can list (skin in the game),
  • LUMEN reputation scoring, with low-trust and duplicate listings filtered out of discovery,
  • Ed25519-signed responses — the provider signs the result object, the hub verifies it, so nobody can swap the payload a caller paid for,
  • and slashing on bad invokes, with the signal federated to peer hubs.

I didn't write any of that. I wrote a 30-line greeter. The trust layer is the hub's job, and it's the difference between "a demo" and "something an autonomous buyer will actually pay."

Try it

It's all MIT. The example, the CLI, and the developer quickstart (in 20 languages) are in the repo:

If "my API, but agents can find it and pay for it" is a thing you've wanted, clone it and publish your own capability — a ⭐ helps other people find it too.

Top comments (0)