Credits API (Python)
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
Python
from therouter import TheRouter.ai
client = TheRouter.ai(
api_key=os.getenv("THEROUTER_API_KEY"),
base_url="https://api.therouter.ai/v1",
)
balance = client.credits.get_balance()
transactions = client.credits.list_transactions(limit=10)
print(balance.total_credits, len(transactions.data))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.