Billing and usage
Prepaid per-token billing: server-side token counting, hourly debits from your balance, and what happens at zero.
Prepaid, per token
AI inference is billed from the same prepaid balance as your apps: you redeem a voucher, the value lands as credit, and token usage is metered against it. There is no subscription and no minimum. A request costs exactly what its tokens cost:
| Rate | Price |
|---|---|
| Input tokens | $0.10 per 1M tokens |
| Output tokens | $0.30 per 1M tokens |
Per-model prices are listed on models and pricing; estimate a workload with the pricing calculator.
Tokens are counted on the server
Billing uses the token counts our gateway captures from the inference
engine, never client-reported numbers. Every response includes them in the
usage object:
"usage": {
"prompt_tokens": 21,
"completion_tokens": 38,
"total_tokens": 59
}In streaming mode the final chunk carries the same usage object (the
gateway forces stream_options.include_usage on), so what you observe in the
response is exactly what you are billed for: prompt_tokens at the input
rate, completion_tokens at the output rate.
Hourly debits
Usage is recorded per request and debited from your balance once per hour, as a single ledger entry per hour of usage. The debits appear in the same transaction history as your voucher credits, on the Billing page in the portal, where credits and charges stay auditable side by side.
Track your token consumption per day and per model on the AI page in the portal, or programmatically (with your portal access token):
curl -sS "https://api.alawadi.cloud/v1/ai/usage?from=2026-06-01&to=2026-06-30" \
-H "Authorization: Bearer $PORTAL_ACCESS_TOKEN"The response is token and request counts only, broken down per day and per model. It does not return money: cost is computed from the rates above, and the actual charges land as the hourly debits in your transaction history.
{
"from": "2026-06-01",
"to": "2026-06-30",
"rows": [
{
"day": "2026-06-12",
"model": "qwen2.5-7b-instruct",
"prompt_tokens": 18240,
"completion_tokens": 9610,
"requests": 142
}
],
"totals": {
"prompt_tokens": 512300,
"completion_tokens": 244180,
"requests": 3120
}
}Export an audit report
For compliance reviews or chargeback, export everything your account did on
the AI surface — inference usage events, the AI key lifecycle (prefixes only,
never secrets), and your agents with their revision history — from
GET /v1/ai/audit (owner-scoped, portal access token):
curl -sS "https://api.alawadi.cloud/v1/ai/audit?from=2026-06-01&to=2026-06-30&format=json" \
-H "Authorization: Bearer $PORTAL_ACCESS_TOKEN"The window defaults to the last 30 days. kind=usage|keys|agents selects a
subset (default: all three); format=csv downloads a spreadsheet-ready file
and requires a single kind, one table per file. Full parameters and schemas
are in the AI Agents API reference.
Zero balance and suspension
A balance pre-check runs on every request, before any tokens are generated:
- Balance at zero (or no balance yet) → the request is rejected with
402and codeINSUFFICIENT_BALANCE. No tokens are consumed and nothing is charged. - Account suspended for billing → requests are rejected with
403and codeACCOUNT_SUSPENDED. This is the same suspension that stops your apps when a balance stays at zero past the grace period.
Both states clear themselves: redeem a voucher and requests start succeeding again. No support ticket needed.
Top up before you run dry
The portal shows a low-balance warning banner well before zero. Because the pre-check runs per request, a mid-stream conversation is never interrupted, but the next request after your balance hits zero returns 402.
Connect your app to AI
Give a container you deployed one-click access to the AI model, with the endpoint and key injected as environment variables.
Limits and errors
Per-key rate and concurrency limits, request caps, completion-length clamps, and every error code the AI gateway returns in the OpenAI envelope.