Configure GalliunClient with your API base URL, target chain, and wallet adapter.

Basic configuration

import { GalliunClient } from "@galliun/sdk";

const client = new GalliunClient({
  baseUrl: "https://api.galliun.com",
  chain: "sui",
  wallet: suiWallet,
});

Options

interface GalliunClientOptions {
  baseUrl: string;           // Required — trailing slash stripped automatically
  chain?: string;            // Target chain for payment selection ("sui" or "solana")
  wallet?: PaymentWalletAdapter;
  fetch?: typeof fetch;      // Custom fetch implementation
  hooks?: PaidAIClientHooks; // Payment flow UI hooks
  authToken?: string;        // Bearer token for authenticated requests
}

Chain and wallet

Both chain and wallet are required for paid requests. The SDK throws sdk_error if either is missing when a 402 is received.

The chain option must match one entry in the 402 accepts array. Supported values:

Chain chain value
Sui "sui"
Solana "solana"

Payment flow hooks

Pass hooks for UI integration (used by playground and dashboard):

const client = new GalliunClient({
  baseUrl: "https://api.galliun.com",
  chain: "sui",
  wallet: suiWallet,
  hooks: {
    onStatusChange: (status) => console.log(status),
    onPaymentRequired: (requirement) => console.log(requirement),
    onPaymentSubmitted: (proof, requirement) => console.log(proof.txHashOrDigest),
  },
});

Hook statuses: idle, sending_request, payment_required, waiting_for_wallet, payment_submitted, retrying_request, verifying_payment, complete, error.

Auth token

Set a bearer token for authenticated endpoints:

client.setAuthToken(accessToken);

Wallet adapters must implement pay() for exact_split x402 payments. signMessage() is optional.

Custom fetch

Inject a custom fetch for testing or middleware:

const client = new GalliunClient({
  baseUrl: "https://api.galliun.com",
  chain: "sui",
  wallet: suiWallet,
  fetch: myCustomFetch,
});

Common mistakes

Next steps