Credits API (TypeScript)

Methods, examples, and parameters for client.credits.

Module Overview

Inspect balances, transaction history, and package purchases for billing workflows.

Available Methods

  • client.credits.getBalance() - Read current remaining credit balance.
  • client.credits.listTransactions() - List historical credit movements.
  • client.credits.purchase() - Create a payment intent for a package.

Examples

TypeScript
import { TheRouter.ai } from "@therouter/sdk";

const client = new TheRouter.ai({ apiKey: process.env.THEROUTER_API_KEY! });

const balance = await client.credits.getBalance();
const tx = await client.credits.listTransactions({ limit: 10 });

console.log(balance.total_credits, tx.data.length);
credits-response.json
{
  "id": "req_01HXYZ123",
  "module": "credits",
  "status": "ok"
}

Parameter Types

NameTypeRequiredDescription
tenant_id
stringTarget tenant if using admin credentials.
limit
integerNumber of transaction rows to return.
status
stringFilter by pending, completed, or failed.
SDK parity
Method signatures are aligned across SDKs so migration between TypeScript and Python stays predictable.