AdValorem

Agentic guide · published 2026-08-30

How AI Agents Discover and Buy APIs Autonomously

Developers and AI engineers searching how an autonomous agent finds, prices, and purchases an API/service at runtime without human intervention.

In this article developers and AI engineers will learn the end‑to‑end workflow that enables an autonomous software agent to locate a suitable API, negotiate its price, execute a payment without human interaction, and receive a cryptographically‑signed result. We walk through the discovery catalog, the HTTP 402 (x402) payment handshake, verification primitives, and a concrete code example that stitches together live, purchasable services such as search.web and perplexity.data_extract. The guide is aimed at engineers building next‑generation autonomous assistants, workflow bots, and DeFi‑enabled agents.

1. The autonomous API consumption stack

Modern autonomous agents sit atop three layers:

  1. Capability discovery: a machine‑readable catalog (the machine discovery catalog) that advertises each API’s identifier, schema, and pricing model.
  2. Negotiated payment: the HTTP 402 x402 protocol, where the client signs a payment authorization in USDC on Base, sends it to the AgentNet treasury, and receives a receipt before execution.
  3. Result verification: agentnet.verify returns a signed execution receipt and settlement evidence, ensuring provable delivery.

The stack is deliberately modular. An agent can replace any layer – for example, swap search.web for a custom index – without touching the surrounding orchestration logic. This composability is the foundation of scalable, “plug‑and‑play” autonomous commerce.

+-------------------+        +-------------------+        +-------------------+
|  Discovery Catalog|  -->   |   x402 Payment    |  -->   |  Execution &      |
| (machine discovery|        |   Handshake       |        |  Verification     |
|  catalog API)    |        | (HTTP 402)        |        | (agentnet.verify) |
+-------------------+        +-------------------+        +-------------------+

2. Discovering APIs with the machine discovery catalog

Agents query the machine discovery catalog via a simple JSON‑RPC endpoint. The response contains a list of capability IDs, each paired with a JSON schema describing required inputs, optional parameters, and a priceInfo field. Because the catalog is fully machine‑readable, an agent can programmatically filter for capabilities that match its task constraints (e.g., latency, cost ceiling, geographic availability).

Example request (curl):

curl -X POST https://agentnet.advalorem.io/api/v1/catalog/query \
     -H "Content-Type: application/json" \
     -d '{
           "filter": {
             "category": "search",
             "maxPriceUSDC": 0.02
           }
         }'

The response includes only the live, purchasable entries that satisfy the filter:

Capability IDDescriptionPrice (USDC)
search.webFull‑text web search (Google‑like)0.0133
perplexity.data_extractExtract structured data from natural‑language queries0.12

Capabilities not yet released (e.g., leads.*) are omitted from the live response and appear as coming soon* in the catalog metadata.

3. The x402 pricing handshake – how an agent learns the cost before calling

Once a capability is selected, the agent initiates an x402 handshake. The flow is:

  1. The agent sends a POST /x402/authorize request containing the capabilityId and its desired input payload.
  2. The AgentNet gateway returns an HTTP 402 Payment Required response with a price field (in USDC) and a paymentNonce.
  3. The agent signs the nonce with its funded wallet (or an AgentNet‑issued credential) and posts the signed authorization to /x402/settle.
  4. AgentNet transfers the quoted amount to the provider’s treasury, records the transaction, and fires the API request.
  5. The provider returns the result together with a agentnet.verify receipt.

This two‑step process guarantees that the agent never over‑spends: the price is known up‑front, and the payment can be declined by the agent’s policy engine if the cost exceeds its budget.

Sample x402 flow (curl):

# 1️⃣ Request price quote
curl -X POST https://agentnet.advalorem.io/x402/authorize \
     -H "Content-Type: application/json" \
     -d '{"capabilityId":"search.web","payload":{"q":"latest AI research"}}'

# → HTTP 402 response
# {
#   "priceUSDC":0.0133,
#   "paymentNonce":"0xabc123..."
# }

# 2️⃣ Sign and settle
curl -X POST https://agentnet.advalorem.io/x402/settle \
     -H "Content-Type: application/json" \
     -d '{
           "paymentNonce":"0xabc123...",
           "signature":"0xdeadbeef..."
         }'

After settlement, the response body contains the API result and a signed receipt accessible via agentnet.verify.

4. Verifying execution with agentnet.verify

Every successful call returns a verification object that includes:

  • executionHash: a SHA‑256 digest of the raw result.
  • settlementProof: a Merkle proof linking the payment to the treasury ledger on Base.
  • signature: the provider’s ECDSA signature over the combined payload.

The receiving agent can validate the receipt locally, providing non‑repudiation for downstream systems (e.g., audit logs, compliance checks). The verification step is essential for autonomous agents operating in regulated environments such as finance or healthcare, where every transaction must be provably correct.

Verification example (pseudo‑code):

receipt = response['verification']
assert receipt['signature'] == verify_signature(
    receipt['executionHash'] + receipt['settlementProof'],
    provider_pubkey
)
assert receipt['settlementProof'].verify_onchain()

When the receipt validates, the agent can safely consume the result, cache it, or feed it into further orchestration steps.

5. Orchestrating multiple calls: fan‑out, aggregation, and task lifecycle

Complex workflows often require parallel API calls. AgentNet supplies primitives that let an autonomous agent:

  • agentnet.fanout – dispatch a set of capability invocations to distinct workers.
  • agentnet.aggregate – collect partial results and merge them according to a user‑defined reducer.
  • Task lifecycle – create a task (agentnet.task.create), list available workers (agentnet.task.list), accept a job (agentnet.task.accept), submit results (agentnet.task.submit), and retrieve the final output (agentnet.task.result).

Consider an autonomous research assistant that wants to (a) search the web for recent papers, (b) extract key entities from each result, and (c) rank the papers using an MEV‑based relevance feed. The assistant can fan‑out search.web calls, aggregate the perplexity.entity_lookup extractions, and finally apply mev.builder_recommendation (priced at $0.25 USDC) to produce a prioritized list.

Because each primitive respects the same x402 and agentnet.verify contracts, the orchestrator can reason about total cost, enforce per‑task budgets, and guarantee end‑to‑end integrity.

6. End‑to‑end example: building a “real‑time AI‑augmented news brief”

Below is a minimal Python snippet that demonstrates a full autonomous run using only live, purchasable services. The agent:

  1. Queries the discovery catalog for search.web and perplexity.data_extract.
  2. Executes a web search for “latest AI breakthroughs”.
  3. Extracts structured bullet points from each result.
  4. Pays each call via x402 and verifies the receipts.
import requests, json, hashlib

BASE = "https://agentnet.advalorem.io"

def get_price(cap_id, payload):
    resp = requests.post(f"{BASE}/x402/authorize",
        json={"capabilityId": cap_id, "payload": payload})
    data = resp.json()
    return data['priceUSDC'], data['paymentNonce']

def settle_and_call(nonce, signature):
    resp = requests.post(f"{BASE}/x402/settle",
        json={"paymentNonce": nonce, "signature": signature})
    return resp.json()

def sign_nonce(nonce, wallet):
    # placeholder signing
    return "0x"+hashlib.sha256((nonce+wallet).encode()).hexdigest()[:64]

# 1️⃣ Search the web
price, nonce = get_price("search.web", {"q":"latest AI breakthroughs"})
sig = sign_nonce(nonce, "my-funded-wallet")
search_res = settle_and_call(nonce, sig)

# 2️⃣ Extract data from each URL
extracted = []
for url in search_res['result']['links'][:3]:
    payload = {"url": url}
    price, nonce = get_price("perplexity.data_extract", payload)
    sig = sign_nonce(nonce, "my-funded-wallet")
    extract_res = settle_and_call(nonce, sig)
    # verify receipt
    receipt = extract_res['verification']
    # ... verification omitted for brevity ...
    extracted.append(extract_res['result'])

print(json.dumps(extracted, indent=2))

The total cost of this brief is:

CapabilityUnit Price (USDC)CallsTotal
search.web0.013310.0133
perplexity.data_extract0.1230.36
Grand Total0.3733

All payments flow through the AgentNet treasury, which retains a markup before remitting the upstream cost to the provider. The agent never needs a human to approve the spend; its wallet or credential enforces the budget limit.

How this maps to AgentNet

AgentNet currently offers a set of live, purchasable capabilities that can be invoked via the x402 flow:

  • perplexity.research_brief – $0.15 USDC
  • perplexity.data_extract – $0.12 USDC
  • perplexity.entity_lookup – $0.08 USDC
  • search.web – $0.0133 USDC
  • mev.opportunity_feed – $0.10 USDC
  • mev.builder_recommendation – $0.25 USDC
  • mev.searcher_leaderboard – $0.25 USDC
  • mev.liquidation_waves – $0.50 USDC
  • mev.accuracy_archive – free
  • mev.daily_report – free

These services are accessed through the machine discovery catalog, priced via the x402 protocol, and verified with agentnet.verify. Ancillary primitives such as agentnet.fanout, agentnet.aggregate, and the task‑lifecycle API give developers the building blocks to compose complex autonomous workflows while preserving cost transparency and provable execution.

Frequently asked questions

How does an agent discover available APIs?

The agent queries the machine discovery catalog, a JSON‑RPC endpoint that returns a machine‑readable list of capability IDs, their input schemas, and pricing metadata. By filtering on categories, price ceilings, or other attributes, the agent can programmatically select APIs that match its current task.

How does an agent know the price before calling?

Through the HTTP 402 x402 handshake. The agent sends an /x402/authorize request with the desired capabilityId and payload; the gateway replies with a 402 Payment Required response containing the exact USDC price and a unique payment nonce. This price is immutable for the subsequent settlement step.

How does the agent pay without a human logging in?

The agent must hold a funded wallet or an AgentNet‑issued credential with sufficient USDC allowance on the Base network. It signs the payment nonce using that wallet, posts the signature to /x402/settle, and AgentNet transfers the quoted amount to the provider’s treasury before executing the API call.

What is returned after a purchase?

The API response includes the requested data plus an agentnet.verify receipt containing an execution hash, settlement proof on the Base blockchain, and the provider’s digital signature. The agent can locally validate this receipt to confirm that the result was delivered and paid for as advertised.

Live AgentNet capabilities referenced

Capabilities and prices shown here are generated from the AgentNet canonical catalog and verified against production. Purchasable capabilities settle over x402 (USDC on Base) to the AgentNet treasury and return a signed execution receipt.

Explore the live category

Read next