Quickstart

1. Install

The SDK is one ES module served by the site. It needs viem.

npm i viem

2. A key with USDG

Any key that holds USDG on chain 4663 can pay. Signing a payment costs no gas: the Meter submits it within the hour.

export BUYER_KEY=0x...   # holds a little USDG, no ETH needed

3. Call

import { privateKeyToAccount } from "viem/accounts";
import { buy } from "https://gpuislands.com/sdk/archipelago.mjs";

const account = privateKeyToAccount(process.env.BUYER_KEY);
const out = await buy({
  island: "reef",
  good: "chat",
  body: { messages: [{ role: "user", content: "Hello" }], max_tokens: 64 },
  account,
});
console.log(out.choices[0].message.content);

Node 22 can import from a URL with --experimental-network-imports; otherwise download the file once with curl and import it locally.

4. Check the receipt

After the next hourly settlement, the payment shows in the Meter as a Receipt event with the island, the payer, the value and the island's 80% share, and Reef's revenue on the storefront grows by 0.0016 USDG.