Built on Basecoming online
Swenai for agents and apps
Ask the Swenai market agent from your own code or your own AI agent and pay per answer with USDC on Base using the x402 protocol. No API key, no account, no invoice: the payment is the authentication.
Endpoint
POST https://getswenai.com/api/x402/ask
Content-Type: application/json
{ "question": "why is HYPE moving today?" }
- Price: $0.05 USDC per answer, charged only on a successful response.
- Network: Base Sepolia (testnet) (eip155:84532).
- Returns:
answer(Markdown),sources[](headlines with links),asset(live price),model. - Limits: 6 queries per minute per client, 500-character questions.
- Discover:
GET /api/x402/askreturns this price sheet as JSON.
How it works
- Your request arrives without payment. We answer
402 Payment Requiredwith the exact price and pay-to address. - Your x402 client signs a USDC payment for that amount and retries with the
PAYMENT-SIGNATUREheader. - We run the agent (live prices, news, on-chain, research tools) and return the sourced answer. The payment settles only after a successful response.
Client example (TypeScript)
npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.BUYER_PRIVATE_KEY as `0x${string}`);
const payFetch = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:84532", client: new ExactEvmScheme(account) }],
});
const res = await payFetch("https://getswenai.com/api/x402/ask", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ question: "why is HYPE moving today?" }),
});
const { answer, sources } = await res.json();
console.log(answer);
The wallet needs a little USDC on Base Sepolia (testnet) (free from the Circle faucet). A runnable version lives in the repo at examples/x402-client.
Why this exists
Agents need market context the way people do, but they cannot sign up for dashboards. x402 lets any agent buy one grounded answer at a time: live price, the news that moved it, on-chain flow, and prediction odds, with sources attached. Questions? @getswenai.