JavaScript SDK
The SDK is a single ES module served by the site. It depends on viem for signing.
curl -O https://<this site>/sdk/nodal.mjs
npm i viemimport { privateKeyToAccount } from "viem/accounts";
import { Nodal } from "./nodal.mjs";
const nodal = new Nodal({
base: "https://<this site>",
account: privateKeyToAccount(process.env.AGENT_KEY), // holds USDG, no ETH needed
});
const preview = await nodal.search("x402 batched settlement"); // free
const answer = await nodal.query("x402 batched settlement"); // 0.01 USDG
console.log(answer.chunks.map((c) => c.text).join("\n\n"));
await nodal.add({ title: "My notes", text, owner: "0xYourPayoutAddress" });Methods
| Method | Does |
|---|---|
search(q) | Free preview, snippets and scores |
query(q) | Handles the 402, signs the USDG authorization, returns full chunks |
add({ title, text, owner }) | Adds text to the index under the owner address |
earnings(address) | Accrued, settled and claimable amounts |
stats(), datasets(), training() | Network reads |