Docs for agents
Connect an agent.
An agent finds the gateway by its ENS name, pays over x402, and gets a receipt. Four steps, and no account to create.
The calls below describe the real behaviour, and they work against a local stack today: run just market-local from the repository and use its URL instead of https://split-fill.vercel.app.
How a read works
- Quote. POST a question with the
X-SplitFill-Poolheader. The gateway answers402and puts an exact x402 v2 quote in thePAYMENT-REQUIREDheader. - Sign. Your wallet signs an EIP-3009 USDC authorization for at most the quoted amount. The payment itself costs no gas.
- Settle. Send it back as
PAYMENT-SIGNATURE. The transfer and the vault record both confirm. - Receipt. You get the answer and a
PAYMENT-RESPONSEreceipt with both transaction hashes. If you are not told the outcome (503), keep the original signed read and retry it. Never pay twice.
Reader n pays ceil(C/n). After N readers, reader i has earned floor(C×(N−i)/(i×N)) back. The pool page shows it move.
Try it with curl
List the pools, then ask for a quote. Asking is free. Nothing is paid until you send a signature.
curl -s https://split-fill.vercel.app/v1/pools | jqPOOL=0x... # a pool_id from the list above
curl -si https://split-fill.vercel.app/v1/chat/completions \
-H "X-SplitFill-Pool: $POOL" \
-H "content-type: application/json" \
-d '{"model":"splitfill-a","messages":[{"role":"user","content":"What changed in fare revenue?"}]}' \
| tr -d '\r' | awk 'tolower($1)=="payment-required:" {print $2}' | base64 -d | jqPay with the Python SDK
The SDK checks every quote against a policy you set: the chain, the token, who gets paid and the most you will spend. It refuses anything outside it. Install it from sdk/python in the repository.
import os
from splitfill import Client, PaymentPolicy, ReadRequest
USDC = "0x036CbD53842c5426634e7929541eC2318f3dCF7e" # Base Sepolia
PAY_TO = "0x..." # the address the gateway asks to be paid at
with Client("https://split-fill.vercel.app") as client:
pool = client.pools(model="splitfill-a")[0]
quote = client.quote(
ReadRequest(
pool_id=pool.pool_id,
model=pool.model,
question="What changed in fare revenue?",
)
)
policy = PaymentPolicy(
chain_id=84532, asset=USDC, recipient=PAY_TO, max_amount=100_000
)
signed = client.sign(quote, policy, os.environ["READER_KEY"])
answer, receipt = client.submit(signed)
print(answer["choices"][0]["message"]["content"])
print("paid", receipt.amount, "in", receipt.transaction)Verify the gateway by its ENS name
Instead of trusting a URL, resolve splitfill.eth. Its records give the endpoint, the address to pay and the payment preference. The policy takes its recipient from the name, so a gateway that asks for a different address is refused before anything is signed. You can check the live records and every reader's consent in your browser.
import os
from splitfill import Client, ReadRequest
from splitfill.client import ProtocolError
from splitfill.identity import EnsResolver, attach_name, policy_for
USDC = "0x036CbD53842c5426634e7929541eC2318f3dCF7e" # Base Sepolia
# 1. Find the gateway by name. Nothing is hard-coded: the endpoint and the
# address to pay both come from ENS on Sepolia.
resolver = EnsResolver.from_rpc("https://ethereum-sepolia-rpc.publicnode.com")
gateway = resolver.resolve_gateway("splitfill.eth")
# 2. The policy takes its recipient from the name, not from the 402.
policy = policy_for(gateway, chain_id=84532, asset=USDC, max_amount=100_000)
with Client(gateway.endpoint) as client:
pool = client.pools(model="splitfill-a")[0]
quote = client.quote(
ReadRequest(pool_id=pool.pool_id, model=pool.model, question="Summarize the filing.")
)
try:
signed = client.sign(quote, policy, os.environ["READER_KEY"])
except ProtocolError:
# The quote asked for a different payTo than the name resolves to.
raise SystemExit("refusing to pay: the gateway does not match its ENS name")
# 3. Optional: claim your own name so the receipt shows it as verified.
signed = attach_name(signed, "reader-1.splitfill.eth")
answer, receipt = client.submit(signed)
print(answer.get("splitfill", {}).get("verified_name"))Rules the gateway enforces
- It overwrites
cache_saltandpriorityand stripskv_transfer_params. Do not send them. - One non-streaming question per request.
- Public reader counts are bucketed (0, 1, 2-4, 5-16, 17+) and delayed.
- Only public documents are pooled.
- Payments round up and rebates round down, so the vault never overpays.
For machines
- /openapi.json: every gateway endpoint, in OpenAPI 3.1.
- /llms.txt: the same story in a form made for language models.
- AGENTS.md: invariants, interfaces and commands.