Guides

Call a capability

Reach any capability on Tael from your own code with a single API key. Payment happens automatically from the Card your key is linked to, so you never sign a transaction yourself.

Setup

Create a key in the dashboard under API Keys and link it to a funded Card. That Card's caps, both per call and per day, bound everything the key is allowed to spend.

›_terminal
pnpm add @tael/sdk
TSsetup.ts
import { Tael } from "@tael/sdk";

const tael = new Tael({ apiKey: process.env.TAEL_KEY! });

Call a capability

Reference a capability by its slug. Both get and post return the response data directly, so there is nothing else to unwrap.

TScall.ts
const facts = await tael.get("cat-facts");
const reply = await tael.post("claude", { prompt: "Summarize this." });

// works for any capability, any method, with one key.
You do not sign anything. Tael pays from the Card your key is linked to, stays within its caps, and hands you back the result.

Discover capabilities

List or search the marketplace to find slugs and prices at runtime.

TSdiscover.ts
const all = await tael.list();               // every capability
const found = await tael.search("weather");  // by name or description

// each: { slug, name, description, kind, method, price, logoUrl, verified }

Receipts

Reach for call() when you want the full response: the data, the HTTP status, and the on-chain settlement receipt.

TSreceipt.ts
const res = await tael.call("cat-facts");
res.data;            // the capability's response
res.status;          // HTTP status
res.receipt?.txHash; // proof the USDC payment settled on Stellar

Errors

When a call fails, the client throws a TaelError that carries the gateway's message and its status code.

  • 401 means the key is unknown or has been revoked.
  • 402 means the linked Card holds no USDC, or no Card is linked at all.
  • 403 means the call exceeds the Card's per-call or daily cap.
TSerrors.ts
import { Tael, TaelError } from "@tael/sdk";

try {
  await tael.post("claude", { prompt: "hi" });
} catch (err) {
  if (err instanceof TaelError) {
    console.error(err.status, err.message); // e.g. 403 "Over this Card's per-call cap."
  }
}

Would you rather publish your own capability? See List your product as a capability.