Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grok usage

A desk display for Moddable Display 2: current time, date, and your personal Grok weekly usage pool — the same meter as Settings → Usage on grok.com / Grok Build. When that pool is empty, it switches to Extra Usage Credits remaining and a derived dollar-per-hour burn.

It uses the Grok CLI login (SuperGrok, X Premium+, and so on). It is not the xAI API console prepaid-credit API. Those are separate products.

grok-usage.mp4

Requires the Moddable SDK and a grok login on the machine you build from.

Build

Pass Wi-Fi and tokens on the mcconfig command line. Do not put them in the repo.

TOKEN=$(python3 -c 'import json,pathlib,sys; d=json.loads(pathlib.Path.home().joinpath(".grok/auth.json").read_text()); e=next(iter(d.values())); sys.stdout.write(e["key"])')
REFRESH=$(python3 -c 'import json,pathlib,sys; d=json.loads(pathlib.Path.home().joinpath(".grok/auth.json").read_text()); e=next(iter(d.values())); sys.stdout.write(e["refresh_token"])')

mcconfig -d -m -p esp32/moddable_display_2 \
  ssid="YourNetwork" password="YourPassword" \
  grokToken="$TOKEN" grokRefresh="$REFRESH"

Simulator (Moddable Two skin):

mcconfig -m -p sim/moddable_two grokToken="$TOKEN" grokRefresh="$REFRESH"

The access token lasts about six hours. Pass grokRefresh so the device can mint a new one; the rotated refresh token is stored in Preferences so the display can keep running.

If the status line says token expired, run grok login again and reflash with fresh tokens.

Config

Key Default Meaning
ssid / password empty Wi-Fi (device only)
grokToken empty Access token from ~/.grok/auth.json
grokRefresh empty Refresh token from the same file
timezone -8 Standard-time offset in hours from UTC
dst auto auto uses US daylight-saving rules; 1 / 0 force on or off
hour12 true false for 24-hour time
lowBalance 20 Remaining weekly percent at which the amount turns red
driverRotation 0 90 or 270 for landscape; 180 for touch orientation

Tap the screen to refresh usage. It also polls every 60 seconds.

When the weekly pool hits 100% and Extra Usage Credits remain, the card shows remaining credits in dollars (USD cents from prepaidBalance), a $/hr burn rate after a few minutes of observed spend, and an estimated time-to-empty. A refill (purchase or auto top-up) resets the burn window. Token counts are not in this API; the weekly pool is compute-metered.

The Grok CLI OAuth client ID is built into the app. You do not pass it.

About

Moddable SDK JavaScript application: Grok weekly usage and extra-credit burn

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages