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
| Name | Type | Required | Description |
|---|---|---|---|
tenant_id | string | Target tenant if using admin credentials. | |
limit | integer | Number of transaction rows to return. | |
status | string | Filter by pending, completed, or failed. |
SDK parity
Method signatures are aligned across SDKs so migration between TypeScript and Python stays predictable.