openclaw/docs
Bobby Bones 7f0ea8e546
fix: SuperGrok usage shows No usage data when xAI omits creditUsagePercent (#155790)
<!--
Related: #155782

Required PR title:
fix: SuperGrok usage shows No usage data when xAI omits creditUsagePercent
-->

Related: #155782

## What Problem This Solves

Fixes: SuperGrok usage cards and `openclaw status --usage` show "No usage data" when xAI returns a valid weekly billing period that omits `creditUsagePercent`.

## User Impact

User impact: OAuth SuperGrok accounts now get a specific "Included usage omitted" snapshot, plus plan and prepaid facts, instead of a generic missing-telemetry error. Grok inference was already working; only quota display was wrong.

## Why This Change Was Made

xAI can omit a default-zero included-usage scalar on an otherwise valid weekly or monthly billing period. The parser now treats that as omitted included usage rather than inventing a percentage or reading on-demand pay-as-you-go counters as SuperGrok subscription quota. Legacy monthly `used` / `monthlyLimit` parsing and explicit `creditUsagePercent: 0` windows stay unchanged.

## Evidence

Exact head: `19aae5939ec429b30333e8db836bf6276d583895`. No code change in this proof pass.

Live usage-only billing probe against `GET https://cli-chat-proxy.grok.com/v1/billing?format=credits` (HTTP 200, 413 bytes). Isolated disposable Gateway on `127.0.0.1:63012` (`openclaw gateway run --dev`). Live operator Gateway on `127.0.0.1:18789` (pid 22298) was not restarted, modified, or used for this proof. No inference requests.

Sanitized live billing payload: valid weekly period, `creditUsagePercent` omitted, no legacy `used` / `monthlyLimit`:

```json
{
  "config": {
    "currentPeriod": {
      "type": "USAGE_PERIOD_TYPE_WEEKLY",
      "start": "2026-09-21T12:01:29.688516+00:00",
      "end": "2026-09-28T12:01:29.688516+00:00"
    },
    "onDemandCap": { "val": 0 },
    "onDemandUsed": { "val": 0 },
    "isUnifiedBillingUser": true,
    "prepaidBalance": { "val": 0 },
    "billingPeriodStart": "2026-09-21T12:01:29.688516+00:00",
    "billingPeriodEnd": "2026-09-28T12:01:29.688516+00:00"
  }
}
```

`has_creditUsagePercent`: false. Period recognized as weekly.

PR-head CLI after the same live account, isolated config/port/session store (exit 0):

```text
pnpm openclaw status --usage --timeout 30000
Usage:
  SuperGrok (SuperGrok)
    Included usage omitted
    Prepaid balance: $0.00
```

```text
pnpm openclaw models status
OAuth/token status
- xai usage: Included usage omitted
```

Before (same payload on current main / pre-fix adapter): `SuperGrok: No usage data`.

Focused tests: `node scripts/run-vitest.mjs extensions/xai/usage.test.ts --maxWorkers=1` — 12 passed. File wall 12.38s on one worker; individual cases 1–9ms.

Inspected, sanitized Provider Plans billing-card pair from exact PR-head Control UI (`19aae5939ec429b30333e8db836bf6276d583895`) with a local mocked `usage.status` renderer. Isolated Vite loopback `http://127.0.0.1:51133/`; live operator Gateway `127.0.0.1:18789` (pid 22298) was not used, restarted, or modified. No inference requests.

**Before** (pre-fix SuperGrok snapshot: `error: "No usage data"`):

![Before: SuperGrok Provider Plans card showing No usage data](https://github.com/user-attachments/assets/e315c018-edd5-4e58-99af-f6cbdebe6b66)

**After** (PR-head SuperGrok snapshot: plan + prepaid `$0.00` + `Included usage omitted`):

![After: SuperGrok Provider Plans card showing Included usage omitted](https://github.com/user-attachments/assets/b6157fb5-1cb8-4876-8e00-2b8321b29a13)

No emails, tokens, account identifiers, or private endpoints. Uploaded via the fork `user-attachments` endpoint after upstream `repository_id` returned 404 (no push on `openclaw/openclaw`).

Remaining semantic uncertainty: omitted `creditUsagePercent` is reported as omitted, not proven 0%. Cross-client reports (including [stablyai/orca#20826](https://github.com/stablyai/orca/issues/20826)) suggest xAI drops default-zero credit fields, but that is not a documented xAI contract.


Made with [Cursor](https://cursor.com)

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-09-23 10:06:33 +05:30
..
.generated feat(openai): add explicit Agents API MVP harness (#151176) 2026-09-22 18:51:10 -07:00
.i18n ci: pack test jobs and add opt-in Spot cron routing (#155403) 2026-09-22 13:08:30 -07:00
announcements
assets docs: alphabetize donors and sponsors and add Red Hat logo (#147302) 2026-09-13 17:27:18 -04:00
automation fix: clear completed subagents from live activity (#155408) 2026-09-22 00:11:09 -07:00
channels fix(telegram): keep rapid message chunks in one turn (#155842) 2026-09-23 00:33:39 +05:30
ci ci: defer native lifecycle matrices to release verification (#156077) 2026-09-23 04:06:04 +00:00
cli fix(doctor): recover retained plugin sources after upgrades (#156052) 2026-09-22 21:14:21 -07:00
concepts fix(gateway): keep agent waits pending until replay is ready (#156078) 2026-09-22 22:15:58 -05:00
diagnostics improve: explain stalled model requests and recovery decisions (#149465) 2026-09-21 06:42:09 +00:00
gateway fix: handle endpoint-protected plists during Gateway activation (#149307) 2026-09-22 20:37:25 -07:00
help feat(xiaomi): add MiMo V2.6 support 2026-09-21 22:27:51 -07:00
images
install fix(update): verify every managed Gateway restart attempt (#155355) 2026-09-22 19:32:37 -07:00
maturity docs: update maturity scorecard (#153186) 2026-09-20 10:41:45 -07:00
nodes fix(mcp): recover expired SSE sessions and speed up parsing (#155497) 2026-09-22 09:13:30 -07:00
platforms improve(android): keep chat photos outside text bubbles (#155338) 2026-09-22 07:47:57 -07:00
plugins fix(telegram): keep a visible outcome when final delivery fails (#155906) 2026-09-23 09:59:35 +05:30
providers fix: SuperGrok usage shows No usage data when xAI omits creditUsagePercent (#155790) 2026-09-23 10:06:33 +05:30
reference perf(sessions): reuse prepared rows for chat history (#156055) 2026-09-23 04:13:16 +00:00
releases docs: illustrate the 2026.9.1 release page (#152988) 2026-09-19 13:48:24 -07:00
security fix(proxy): keep WebChat and Codex loopback calls direct (#154013) 2026-09-20 21:42:01 -07:00
snippets/plugin-publish chore(deps): refresh dependencies with seven-day cutoff (#149908) 2026-09-16 09:06:40 -07:00
specs
start feat: run Code Mode on Node or isolated QuickJS (#154522) 2026-09-21 17:33:04 -07:00
tools fix: prevent helper completions from restarting stopped work (#156124) 2026-09-23 05:02:19 +01:00
web fix(ui): repair keyboard access, screen reader semantics, and contrast (#156050) 2026-09-23 02:12:50 +00:00
agent-runtime-architecture.md fix(workers): retain canceled inputs through preparation (#152544) 2026-09-20 04:24:24 -07:00
AGENTS.md
auth-credential-semantics.md perf(infra): reuse SQLite readers in detached Gateway callbacks (#155779) 2026-09-22 12:34:25 -07:00
ci.md ci: streamline main Docker update smoke (#156097) 2026-09-22 19:53:22 -07:00
date-time.md
docs.json feat: run Code Mode on Node or isolated QuickJS (#154522) 2026-09-21 17:33:04 -07:00
docs_map.md
index.md
logging.md fix(sessions): log reclamation Worker failure reasons (#153390) 2026-09-19 21:59:35 -07:00
nav-tabs-underline.js
network.md
openclaw-agent-runtime.md
prose.md
style.css
vps.md
whatsapp-openclaw.jpg