@quetra/sdk

TypeScript client library for AI agent spending governance. Works with any agent framework — LangChain, Claude Agent SDK, Vercel AI SDK, or custom implementations.

Installation

npm install @quetra/sdk
# or
pnpm add @quetra/sdk

Quick Setup

import { QuetraClient } from "@quetra/sdk";

const client = new QuetraClient({
  apiKey: process.env.QUETRA_API_KEY!,
  agentId: "your-agent-uuid",
  gatewayUrl: "https://gateway.quetra.dev", // default
});

Methods

MethodDescription
evaluate(opts)Evaluate a transaction against mandate rules
fetch(url, opts)HTTP fetch with automatic x402 payment handling
getActiveMandate()Get the agent's active mandate
getBudgetStatus()Check remaining budget and limits
canSpend(opts)Check if a spend would be approved, with rejection reasons
getTransactions(opts)List recent transactions
acpCheckout(opts)Initiate Stripe ACP merchant checkout
stripeCharge(opts)Evaluate and create Stripe PaymentIntent

x402 Payment Flow

client.fetch() automatically handles the x402 payment protocol:

// 1. Initial request to paid API
// 2. Receives 402 Payment Required with PAYMENT-REQUIRED header
// 3. Parses payment requirements (amount, vendor, category)
// 4. Calls gateway /x402/pay to evaluate + sign payment
// 5. Retries original request with PAYMENT-SIGNATURE header
// 6. Returns the API response

const data = await client.fetch("https://paid-api.example.com/research");

Environment Variables

QUETRA_API_KEY=sk_your_api_key_here
QUETRA_AGENT_ID=your-agent-uuid
QUETRA_GATEWAY_URL=https://gateway.quetra.dev  # optional, default

Links