Skip to content

Feature proposal: inspect and redeem Grok reset coupons via management API + CLI #4305

Description

@lidge-jun

Area

Provider adapters

What are you trying to accomplish?

Let operators inspect and redeem Grok billing reset coupons (Codex-style usage-reset credits) directly through OpenCodex, using the xAI OAuth tokens already stored — no browser session.

What prevents this today?

OpenCodex only provides quota reset credit inspection and consumption for Codex/ChatGPT accounts (`/api/codex-auth/reset-credits`, `ocx account reset-credits`). Grok reset coupons are served by `prod_mc_billing.ConsumerUiSvc` over binary gRPC-Web and have no management API or CLI surface, so the only way to see or spend one is the grok.com web UI with devtools open.

What should OpenCodex do?

  1. Expose `GET /api/grok/reset-coupons?accountId=` to inspect remaining reset tokens and validity windows.
  2. Expose `POST /api/grok/reset-coupons/consume` to redeem one with durable UUIDv4 operation-id idempotency (journal before fetch; identical ids replay; foreign ids 409; exhausted ledger 503).
  3. Provide `ocx account grok-reset-coupons [--consume --yes --token-id ] [--operation-id ]` mirroring the `reset-credits` safety flags.

Example usage or interface

```bash
ocx account grok-reset-coupons
ocx account grok-reset-coupons --consume --yes --operation-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
```

Alternatives or workarounds

Manually inspecting and redeeming coupons in a web browser using devtools network payloads.

Additional context

Contract verified live against `grok.com` (`GetRemainingResets` / `RedeemReset`): binary gRPC-Web framing (`application/grpc-web+proto`, 5-byte envelope), `Authorization: Bearer ` + `X-XAI-Token-Auth: xai-grok-cli`, no cookies. Response tokens carry `tokenId` plus validity start/end timestamps.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or requestproviderProvider adapters, OpenAI-compat presets, upstream API quirksproxyHTTP proxy, routing, reverse-proxy / management auth

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions