Account
Activation, balance, top-up, keys and tier management.
Overview
Base path:
/v1/accountPython namespace:
accounttext
# Python
from infrai import account
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.accountMethods
account.activate
POST /v1/activate
Onboard with one call: anonymous account, project key and trial credit (Python).
Python
python
infra.activate(*, region="auto", device_kind="cli", write_credentials=True) -> ActivateResultTypeScript
typescript
// activation runs via the CLI / infra.activate() in Python; the JS client takes a key directlyParameters
| Name | Type | Required | Description |
|---|---|---|---|
region | "auto" | "western" | "china" | Optional | Region to activate in. |
write_credentials | boolean | Optional | Persist credentials locally after activation. |
Returns
ActivateResult { account_id, project_id, primary_api_key, trial_credit_usd, checkout_url }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
# One-line onboarding: anonymous account + device fingerprint + trial credit.
act = infra.activate()
print("activated:", act.ok, "| trial: $%.2f" % act.trial_credit_usd)account.balance
GET /v1/account/balance
Read the wallet balance.
Python
python
account.balance()TypeScript
typescript
client.account.balance(): Promise<{ balance_usd, currency }>Returns
{ balance_usd, currency }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
bal = account.balance()
print("balance: $%s %s" % (bal.get("balance_usd"), bal.get("currency", "USD")))account.topup
POST /v1/account/topup
Top up the wallet; returns a checkout URL — the SDK never touches card data.
Python
python
account.topup(amount_usd=..., return_url=None, idempotency_key=None)TypeScript
typescript
client.account.topup(opts: TopupOptions): Promise<TopupRecord>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
amount_usd | number | Required | Top-up amount in USD. |
return_url | string | Optional | Where to return after checkout. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
TopupRecord { topup_id, amount_usd, state, next_action_url? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
# Returns a hosted checkout_url to hand the user; the SDK never touches card data.
t = account.topup(
amount_usd=25.0,
return_url="https://app.example.com/billing/return",
)
print("state:", t.get("state"))
print("complete payment at:", t.get("checkout_url") or t.get("next_action_url"))account.keys.list
GET /v1/account/keys
List the project keys on the account.
Python
python
account.keys.list()TypeScript
typescript
// see ROUTES["account.keys.list"]Returns
{ items: Array<{ key_id, label, scopes, created_at }> }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
for k in account.keys.list().get("items", []):
print(k.get("key_id"), k.get("label"), k.get("created_at"))account.tier.upgrade
POST /v1/account/tier/upgrade
Upgrade the account to a target tier.
Python
python
# see capability account.tier.upgradeTypeScript
typescript
client.account.tier.upgrade(target_tier: string): Promise<AccountSummary>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target_tier | string | Required | Tier id to upgrade to. |
Returns
AccountSummary { account_id, kind, status, tier, balance_usd }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import account
print("tier:", account.tier.upgrade(target_tier="pro").get("tier"))