Read your DA totals and track micro-DA balance via the credits API.
OpenDunes accounts are prepaid. You deposit Algerian Dinars (DA) via SATIM — CIB or Edahabia card — and the balance is deducted per request based on token usage.
Balances are stored in micro-DA: 1 DA = 1,000,000 micro-DA (bigint — no floats). The credits API returns DA values derived from those integers.
GET /api/v1/credits returns:
| Field | Type | Description |
|---|---|---|
data.total_credits | number | Total DA ever credited to the wallet |
data.total_usage | number | Total DA ever spent on requests |
Every successful inference response also carries:
That is the remaining balance in micro-DA after the current request was deducted. Reading this header is the fastest way to keep a live balance display without a separate API call.
When a request would exceed the available balance, the API returns HTTP 402:
Catch this and redirect your user to deposit at /dashboard/billing.
Each request costs (input_tokens × input_rate) + (output_tokens × output_rate), rounded up to the nearest micro-DA (minimum 1). Rates are shown on each model's page in DA per million tokens