grok

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package grok implements the Grok (xAI) usage provider.

Auth: Usage Buttons Helper extension with the user's grok.com browser session (cookies). Endpoint: POST /rest/rate-limits with a JSON body specifying {requestKind, modelName}. We hit it twice — once for grok-3 and once for grok-4-heavy — mirroring how grok.com's own /usage page (and the JoshuaWang2211/grok-usage-watch extension) fetches limits.

Unlike Perplexity's rate-limit endpoint, Grok's response includes total* values alongside remaining*, so we render honest count tiles (X/Y) per category. windowSizeSeconds is the rolling-window length and is intentionally NOT used as a reset countdown — it doesn't say when the current window opened, so deriving "time until reset" from it would re-anchor on every poll. The countdown only fires when the API explicitly hands us a waitTimeSeconds (rate-limited state).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct{}

Provider fetches Grok usage data.

func (Provider) BrandBg

func (Provider) BrandBg() string

BrandBg returns the background color used on button faces.

func (Provider) BrandColor

func (Provider) BrandColor() string

BrandColor returns the accent color used on button faces. Grok renders as a reference card (no meter fill — see Ratio=nil in countMetric), so BrandColor only colors the watermark glyph, value text, and caption. White on a black canvas matches xAI's monochrome presentation.

func (Provider) Fetch

Fetch returns the latest Grok quota snapshot.

func (Provider) ID

func (Provider) ID() string

ID returns the provider identifier used by the registry.

func (Provider) MetricIDs

func (Provider) MetricIDs() []string

MetricIDs enumerates the metrics this provider can emit.

func (Provider) Name

func (Provider) Name() string

Name returns the human-readable provider name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL