Skip to content

feat(api): support Grok subscription image generation - #15423

Merged
diegosouzapw merged 7 commits into
diegosouzapw:release/v3.8.52from
QuangBlue:feat/grok-subscription-images
Oct 7, 2026
Merged

diegosouzapw merged 7 commits into
diegosouzapw:release/v3.8.52from
QuangBlue:feat/grok-subscription-images

Conversation

@QuangBlue

@QuangBlue QuangBlue commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Grok subscription OAuth connections previously could not resolve image models through /v1/images/generations. Register Grok Imagine Image 2.0 and the existing Imagine models for grok-cli/gc and xai-oauth/xao, and add Image 2.0 to xAI API-key connections. Requests reuse the existing OAuth refresh, persistence and account-selection path and dispatch to the xAI image endpoint.

Translate OpenAI pixel sizes into xAI aspect ratio/resolution, preserve explicit native options, map high/hd to medium and standard to low, and validate options before dispatch. Older Imagine models reject the unsupported quality option. Document the callable model IDs and request contract.

Validation

  • Change type: provider / API
  • Final focused image handler, route, registry and credential retry tests: 73 passed on the company main integration branch
  • npm run test:vitest: 54 files / 493 tests passed
  • npm run typecheck:core
  • npm run lint (full repository) and ESLint on all changed TypeScript files
  • node scripts/check/check-api-typecheck.mjs (new diagnostic fixed; existing baseline preserved)
  • npm run check:provider-consistency and npm run check:provider-assets
  • provider-translate-path-golden.test.ts: 2 passed / 1 failed on macOS; the only snapshot differences are existing Copilot user-agent platform strings (linux versus darwin). This PR does not change the chat provider builders or their golden snapshot.
  • npm run check:docs-all
  • Pre-commit and commit-message gates
  • Full npm run test:unit was started and stopped after failures outside the image change. A separate run on unmodified company main (48bcfc9556) reproduced failures in stream-chunk lifecycle, early keepalive logging, Claude cooldown escalation and relay error handling (25 passed / 6 failed). These files and their implementation are unchanged by this PR.
  • CI still has inherited failures: dependency audit in the Lint job (unchanged lockfile), translation drift for docs/architecture/QUALITY_GATES.md, and generated omni-providers skill drift (unchanged generator inputs). The feature guide is a separate document; the API reference translation drift introduced by the initial draft was removed.

Tests Added Or Updated

  • tests/unit/image-xai-subscription.test.ts: provider aliases/catalog, native options, size and quality mapping, invalid inputs and legacy model behavior.
  • tests/unit/image-generation-route.test.ts: API-key and both OAuth providers, catalog visibility, token refresh persistence and validation before upstream dispatch.

Coverage Notes

The new adapter's branches are exercised by deterministic payload tests; route tests cover credential selection, actual dispatch and persisted token rotation. No credentials or generated media are included in this change.

Reviewer Notes

⚠️ base-red inherited: #15306. The baseline failures above remain outside this feature branch. All focused feature checks pass.

Before implementation, a live subscription OAuth call to https://api.x.ai/v1/images/generations with grok-imagine-image-2.0, aspect_ratio: "3:2", resolution: "1k", quality: "medium" and response_format: "b64_json" returned HTTP 200 and an image. Entitlements and quota remain upstream-controlled.

Provider contract: https://docs.x.ai/developers/model-capabilities/images/generation

Quang Blue and others added 6 commits October 3, 2026 13:42
Register the xai-oauth and grok-cli image routes, and remap OpenAI quality
high/hd, only when GROK_SUBSCRIPTION_IMAGES_ENABLED is true. While the flag
is off, the API-key xAI image path stays on the existing request.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 4e1f541 into diegosouzapw:release/v3.8.52 Oct 7, 2026
7 of 9 checks passed
diegosouzapw added a commit that referenced this pull request Oct 7, 2026
Records the Onda B quality drift on the post-squash tip `9214916a`. Product squashes do not carry the baseline.

File-size ceilings inside `frozen`, measured with `split("\n").length`:

- `browser-worker.ts` 4398 → 4467 (#15615)
- `EndpointPageClient.tsx` 2493 → 2531 (#15565)
- `SystemStorageTab.tsx` 1611 → 1619 (#15565)
- `imageGeneration.ts` 3346 → 3377 (#15423, #15513)
- `catalog.ts` 2127 → 2130 (#15701)
- `auth.ts` 3666 → 3668 (#15624)

`node scripts/check/check-file-size.mjs` passed. The legacy string map was not edited.

⚠️ base-red inherited: #15306
diegosouzapw added a commit that referenced this pull request Oct 8, 2026
Drains 9 v3.8.52 tip unit reds: 3 production defects — MCP bundle startup deadlock (async ESM init cycle from #13739; lazy-load cleanModelName), client bundles pulling server-only DB via imageRegistry→featureFlags (#15423; dependency-free resolver bridge, DB override preserved, default OFF), zh-CN/zh-TW glossary violations (#15138/#15092) — plus regenerated route namespaces, env-isolated guide-settings test, auth-test alignments that keep (and tighten to count=2) the loopback/management guards, quota-card guard following #15138 redesign, and stryker listing of 2 tip covering tests. Combined-board validation with #15903: 327/329 on the previously red files, typechecks, lint, 22 gates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants