Monetize a code-execution API for agents
Charge agents per run in USDC. Give agents a sandbox to execute code and bill each run before the container starts.
Agents write code constantly, and they need somewhere safe to run it: a data transform, a quick script, a generated function under test. A sandbox that spins up a clean container per run is real infrastructure, and agents want to pay for the runs they trigger rather than reserve capacity.
Loomal lets your execution service charge per run in USDC over x402. The agent submits code and inputs, pays for the run, and gets back stdout, results, and exit status. The container only boots after the payment settles.
Bill per run, or by the compute it burns
A flat per-run price is simple and predictable: every execution costs the same. It fits agents that run short scripts and want no surprises.
For heavier work you can price by limits. A run with more CPU, memory, or a longer timeout can carry a higher charge, so a quick eval stays cheap while a long-running job pays for the capacity it holds.
Settle before the container boots
Wrap your run handler with requirePayment so the sandbox only provisions after payment. The agent sends code and a runtime, Loomal runs the x402 handshake and settles on Base, and your executor returns the output.
import { requirePayment } from "@loomal/sdk";
export const POST = requirePayment(
{ price: "$0.008" },
async (req) => {
const { code, runtime } = await req.json();
return Response.json({ result: await sandbox.run(code, runtime) });
},
);Be the sandbox agents reach for
Your execution service lists in the Loomal marketplace and the x402 discovery feed, with supported runtimes and limits in the listing. An agent that needs to run generated code finds your endpoint and pays per run with no onboarding.
Settlement is USDC on Base to a non-custodial wallet, and each run produces a signed receipt so every execution you billed is provable.
FAQ
Can I price by CPU time or memory?
Yes. Quote the price from the requested limits or measured usage so heavier runs cost more than light ones.
What if the code fails or times out?
You decide. Return the error and exit code with or without billing, since payment is tied to your handler running.
Do agents need an API key?
No. The x402 handshake pays and authenticates together, so there are no keys to issue.
Start selling to agents.
Wrap an endpoint, set a price, get paid in USDC.